Locale-Sensitive JavaScript Method
date.getUTCDay();
Internationalization (I18n) Method Overview
The getUTCDay method returns the numeric day of the week for the date object (0 for Sunday), based on UTC (Universal Time Zone).
Click here (w3schools) and
here (MDN) for additional details.
I18n Issues
Whether or not calling getDay is an i18n issue is dependent on how it is being used in the application.
Some possible issues are:
- UTC (Universal Time Zone) is being used rather than either the system's local time zone or the application's time zone.
- The returned number is being used to format a date string for display, rather than using the locale to determine the preferred date order and display.
- The day of the week is being compared against a fixed starting weekday value (for example, 0 for Sunday).
Suggested Replacement
To address the first i18n issue, call getDay to use the local time zone rather than UTC.
To set the time zone, call one of the locale-sensitive date methods:
toLocaleDateString
toLocaleString
toLocaleTimeString
These locale-sensitive date methods also address the second i18n issue: that of formatting dates based on locale.
Lastly, 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
|