Internationalization and localization tools


Locale-Sensitive JavaScript Method

date.setTime(milliseconds);

Internationalization (I18n) Method Overview

The setTime method sets the date object to a date/time by adding or subtracting the milliseconds parameter from January 1, 1970 00:00:00 UTC.

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

I18n Issues

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

  • After the call to setTime, the resulting date object is displayed in the UI. This results in using JavaScript's default date format and the system's local time zone, for example: Wed Sep 10 2014 16:11:22 GMT-0600 (Mountain Daylight Time), which would be incorrect for other locales.

Suggested Replacement

To address the i18n issue, call one of the following locale-sensitive date methods, which supports setting the time zone as well as using the locale to format the date/time:

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