mirror of
https://github.com/samsonjs/strftime.git
synced 2026-03-25 09:05:48 +00:00
Fix conversion of date to UTC
Method based on one of SO answers: http://stackoverflow.com/questions/948532/how-do-you-convert-a-javascript-date-to-utc
This commit is contained in:
parent
9e191bf5c6
commit
b0a4d5a84a
2 changed files with 11 additions and 4 deletions
14
strftime.js
14
strftime.js
|
|
@ -279,10 +279,16 @@
|
|||
});
|
||||
}
|
||||
|
||||
function dateToUTC(d) {
|
||||
var msDelta = (d.getTimezoneOffset() || 0) * 60000;
|
||||
return new Date(d.getTime() + msDelta);
|
||||
}
|
||||
function dateToUTC(d) {
|
||||
return new Date(
|
||||
d.getUTCFullYear(),
|
||||
d.getUTCMonth(),
|
||||
d.getUTCDate(),
|
||||
d.getUTCHours(),
|
||||
d.getUTCMinutes(),
|
||||
d.getUTCSeconds(),
|
||||
d.getUTCMilliseconds());
|
||||
}
|
||||
|
||||
var RequiredDateMethods = ['getTime', 'getTimezoneOffset', 'getDay', 'getDate', 'getMonth', 'getFullYear', 'getYear', 'getHours', 'getMinutes', 'getSeconds'];
|
||||
function quacksLikeDate(x) {
|
||||
|
|
|
|||
|
|
@ -104,6 +104,7 @@ assert.format('%y', '11')
|
|||
assert.format('%Z', null, 'GMT')
|
||||
assert.format('%z', null, '+0000')
|
||||
assert.format('%%', '%') // any other char
|
||||
assert.format('%F %T', null, '1970-01-01 00:00:00', new Date(0))
|
||||
ok('GMT')
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue