Internationalization and localization tools


Locale-Sensitive JavaScript Method

date.toISOString();

Internationalization (I18n) Method Overview

The toISOString method returns the date/time of the date object in the ISO 8601 Standard format, where the date order is year, month, day, the time style is 24-hour, and the time zone is UTC (indicated by Z).

For example:

var date = new Date("9/17/2014 11:35 MDT");
var result = date.toISOString();

Result is:

result: 2014-09-17T17:35:00.000Z

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

I18n Issues

Whether or not calling toISOString is an i18n issue is dependent on how it is being used in the application. If the date string is not to be displayed in the UI, then there is no need to change it in an internationalized application; this is the preferred formatting for internal dates and times. However, if you do want to format the date based on the preferred format of the application's locale, then you will need to replace this method call.

Suggested Replacement

To format the date/time based on locale, call one of the following methods:

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