Internationalization and localization tools


Locale-Sensitive JavaScript Method

date.toDateString();

Internationalization (I18n) Method Overview

The toDateString method returns the date part of the date object formatted in U.S. English.

For example:

var date = new Date();
var result = date.toDateString();
The result is:

result: Wed Sep 17 2014

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

I18n Issues

Whether or not calling toDateString 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. 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 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