Internationalization and localization tools


Locale-Sensitive JavaScript Method

date.setUTCMonth(month);
date.setUTCMonth(month, day);

Internationalization (I18n) Method Overview

The setUTCMonth method sets the month (0-11) and optional day for the date object, based on UTC (Universal Time Zone).

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

I18n Issues

Whether or not calling setUTCMonth is an i18n issue is dependent on how it is being used in the application. Two possible issues are:

  • UTC time zone is being used rather than either the system's locale time zone or the application's time zone. It is usually recommended that all stored dates be in UTC time zone so that they can be retrieved and displayed based on the application's time zone.
  • The month + day value is assumed to be the start of the week rather than using the locale to determine the start of the week.

Suggested Replacement

Although you can call setMonth to use the local time zone rather than UTC, we recommend that you keep the call to setUTCDate. Then, when displaying the date, call one of the locale-sensitive date methods, which support setting the time zone as well as using the locale to format the date:

toLocaleDateString
toLocaleString
toLocaleTimeString

To support the weekday starting value based on locale, you will need to either use a 3rd party javascript calendar library or retrieve the value from a locale-sensitive resource file.


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