Locale-Sensitive JavaScript Constructor
new Date();
new Date(value);
new Date(dateString);
new Date(year, month, day, hour, minute, second, millisecond);
Internationalization (I18n) Method Overview
The resulting object of all the Date constructors is a time value that is represented as the number of milliseconds since
January 1, 1970 00:00:00 UTC. UTC stands for Universal Coordinated Time and is the World Time Standard; it is also referred to as Greenwich Mean Time (GMT).
With the exception of the dateString constructor, the constructors use the system's time zone.
Without parameters, the time value is based on the current date/time. If numeric date arguments are missing, they will
be initialized to default values (1 for day, others set to 0). The dateString parameter is a string that
must be in a format that Date.parse is able to parse.
Some examples that will return the same UTC time value, using the system's time zone (MDT):
var myDate1 = new Date();
var myDate2 = new Date(1409840410030);
var myDate3 = new Date("2014-09-04 8:20:10:30 MDT");
var myDate4 = new Date(2014, 9, 4, 8, 20, 10, 30);
The myDate objects will have the same time value of 1409840410030 .
Click here (w3schools) and
here (MDN) for additional details.
I18n Issues
JavaScript dates are often based on the system's time zone, rather than an application's specified time zone. In addition, the dateString
parameter must be in a fixed format, independent of locale. You will need to look at each Date call to ensure that it is performing as expected
once your application supports multiple locales and a time zone other than your system time zone.
Suggested Replacement
When passing in the dateString parameter, make sure it is in a supported locale-independent format; include the time zone when you want the date to
use other than the local system's time zone. For all other constructors, you will need to adjust the time value to support other than the local system's time zone.
Globalyzer will detect this constructor 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
|