Date.js: add the missing date argument to Ox.getTimezoneOffset (the current timezone's offset may have been different in the past); return '+0000', not '-0000', in Ox.getTimezoneOffsetString; correct a test for Ox.makeDate
This commit is contained in:
parent
4b8c1a7d6b
commit
a34c406d78
1 changed files with 11 additions and 7 deletions
|
@ -185,20 +185,24 @@ Ox.getTime = function(utc) {
|
|||
|
||||
/*@
|
||||
Ox.getTimezoneOffset <f> Get the local time zone offset in milliseconds
|
||||
([date]) -> <n> Offset in milliseconds
|
||||
date <d|u> Return offset at this date (if undefined, return current offset)
|
||||
@*/
|
||||
Ox.getTimezoneOffset = function() {
|
||||
return new Date().getTimezoneOffset() * 60000;
|
||||
Ox.getTimezoneOffset = function(date) {
|
||||
return Ox.makeDate(date).getTimezoneOffset() * 60000;
|
||||
};
|
||||
|
||||
/*@
|
||||
Ox.getTimezoneOffsetString <f> Get the local time zone offset as a string
|
||||
Returns a time zone offset string (from around '-1200' to around '+1200').
|
||||
([date]) -> <s> Offset as a string
|
||||
date <d|u> Return offset at this date (if undefined, return current offset)
|
||||
> Ox.getTimezoneOffsetString(new Date('01/01/2000')).length
|
||||
5
|
||||
@*/
|
||||
Ox.getTimezoneOffsetString = function(date) {
|
||||
var offset = (Ox.makeDate(date)).getTimezoneOffset();
|
||||
return (offset < 0 ? '+' : '-')
|
||||
var offset = Ox.makeDate(date).getTimezoneOffset();
|
||||
return (offset <= 0 ? '+' : '-')
|
||||
+ Ox.pad(Math.floor(Math.abs(offset) / 60), 2)
|
||||
+ Ox.pad(Math.abs(offset) % 60, 2);
|
||||
};
|
||||
|
@ -235,12 +239,12 @@ Ox.isLeapYear = function(year, utc) {
|
|||
|
||||
/*@
|
||||
Ox.makeDate <f> Takes a date, number or string, returns a date
|
||||
> Ox.formatDate(Ox.makeDate(new Date('01/01/1970')), '%m/%d/%Y')
|
||||
'01/01/1970'
|
||||
> Ox.formatDate(Ox.makeDate(0), '%m/%d/%Y')
|
||||
> Ox.formatDate(Ox.makeDate(0), '%m/%d/%Y', true)
|
||||
'01/01/1970'
|
||||
> Ox.formatDate(Ox.makeDate('01/01/1970'), '%m/%d/%Y')
|
||||
'01/01/1970'
|
||||
> Ox.formatDate(Ox.makeDate(new Date('01/01/1970')), '%m/%d/%Y')
|
||||
'01/01/1970'
|
||||
@*/
|
||||
Ox.makeDate = function(date) {
|
||||
// if date is a date, new Date(date) makes a clone
|
||||
|
|
Loading…
Reference in a new issue