Internationalization and localization tools


Locale-Sensitive JavaScript Method

date.getTimezoneOffset();

Internationalization (I18n) Method Overview

The getTimezoneOffset method returns the difference in minutes between the date's UTC value (Universal Coordinated Time) and the system's local time zone value. A positive value means that the local time zone is behind UTC; a negative value means it is ahead of UTC.

Click here (w3schools) and here (MDN) for additional details.

I18n Issues

Whether or not calling getTimezoneOffset results in an i18n issue is dependent on how it is being used in the application. One possible issue is:

  • getTimezoneOffset only supports local time; it cannot not be used to support an application's time zone setting.

Suggested Replacement

If you need to support a time zone other than the system's local time zone, you will need to replace this method. We recommend that you store dates/times in UTC and then, when displaying to the user, you convert to the desired time zone. Call one of the following JavaScript methods to display dates and times based on locale, with support for specifying the time zone:

toLocaleDateString
toLocaleString
toLocaleTimeString


Globalyzer will detect this method and report it as an i18n issue. If you have determined that the call is being handled correctly, you can use Globalyzer's Ignore Comment functionality to ensure that it isn't picked up in a subsequent scan.



Locale-Sensitive JavaScript Methods

 

Lingoport internationalization and localization services and software