Skip to content
This repository was archived by the owner on Apr 14, 2021. It is now read-only.

Commit bc17e4c

Browse files
committed
Format UTC date only if specified with { timeZone: "UTC" } (fixes #59)
1 parent 6029ad3 commit bc17e4c

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

Intl.complete.js

+10-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Intl.js

+10-9
Original file line numberDiff line numberDiff line change
@@ -2569,20 +2569,21 @@ function ToLocalTime(date, calendar, timeZone) {
25692569
// for local time zone adjustment and daylight saving time adjustment imposed by
25702570
// ES5, 15.9.1.7 and 15.9.1.8.
25712571
// ###TODO###
2572-
var d = new Date(date);
2572+
var d = new Date(date),
2573+
m = 'get' + (timeZone || '');
25732574

25742575
// 2. Return a Record with fields [[weekday]], [[era]], [[year]], [[month]], [[day]],
25752576
// [[hour]], [[minute]], [[second]], and [[inDST]], each with the corresponding
25762577
// calculated value.
25772578
return new Record({
2578-
'[[weekday]]': d.getUTCDay(),
2579-
'[[era]]' : +(d.getUTCFullYear() >= 0),
2580-
'[[year]]' : d.getUTCFullYear(),
2581-
'[[month]]' : d.getUTCMonth(),
2582-
'[[day]]' : d.getUTCDate(),
2583-
'[[hour]]' : d.getUTCHours(),
2584-
'[[minute]]' : d.getUTCMinutes(),
2585-
'[[second]]' : d.getUTCSeconds(),
2579+
'[[weekday]]': d[m + 'Day'](),
2580+
'[[era]]' : +(d[m + 'FullYear']() >= 0),
2581+
'[[year]]' : d[m + 'FullYear'](),
2582+
'[[month]]' : d[m + 'Month'](),
2583+
'[[day]]' : d[m + 'Date'](),
2584+
'[[hour]]' : d[m + 'Hours'](),
2585+
'[[minute]]' : d[m + 'Minutes'](),
2586+
'[[second]]' : d[m + 'Seconds'](),
25862587
'[[inDST]]' : false // ###TODO###
25872588
});
25882589
}

0 commit comments

Comments
 (0)