Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
fixed issue with ISO_8601 format
Browse files Browse the repository at this point in the history
  • Loading branch information
constantology committed Feb 11, 2012
1 parent 7c8bda0 commit 9ebdfab
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 79 deletions.
78 changes: 39 additions & 39 deletions d8.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
return this;
}

function clone() { return new Date( this.valueOf() ); }
function clone() { return new Date( this.getTime() ); }

function dayOfYear() {
LOCALE.setLeapYear( this );
Expand All @@ -119,7 +119,7 @@
return new Date( this.getFullYear(), m, LOCALE.day_count[m] );
}

function setWeek( v ) { this.setMonth( 0 ); this.setDate( 1 ); return ( this.adjust( Date.DAY, v * 7 ) ).valueOf(); }
function setWeek( v ) { this.setMonth( 0 ); this.setDate( 1 ); return ( this.adjust( Date.DAY, v * 7 ) ).getTime(); }

function timezone() {
var s = this.toString().split( ' ' );
Expand Down Expand Up @@ -261,8 +261,8 @@
cache_format = {}, cache_parse = {},
date_chars, date_members = [DAY, DAYWEEK, DAYYEAR, MONTH, WEEK, YEAR],
filter, formats = copy( {
ISO_8601 : 'Y-m-d<T>H:i:sP', ISO_8601_SHORT : 'Y-m-d',
RFC_850 : 'l, d-M-y H:i:s T', RFC_2822 : 'D, d M Y H:i:s O',
ISO_8601 : 'Y-m-d<T>H:i:s.u<Z>', ISO_8601_SHORT : 'Y-m-d',
RFC_850 : 'l, d-M-y H:i:s T', RFC_2822 : 'D, d M Y H:i:s O',
sortable : 'Y-m-d H:i:sO'
}, LOCALE.formats ),
m, math_fn = { day : ['getDate', 'setDate'], hr : ['getHours', 'setHours'], min : ['getMinutes', 'setMinutes'], month : ['getMonth', 'setMonth'], ms : ['getMilliseconds', 'setMilliseconds'], sec : ['getSeconds', 'setSeconds'], week : ['getWeek', 'setWeek'], year : ['getFullYear', 'setFullYear'] },
Expand All @@ -276,50 +276,50 @@

filter = {
// day
d : function( d ) { return pad( d.getDate(), 2 ); }, // Day of the month, 2 digits with leading zeros
D : function( d ) { return LOCALE.days[d.getDay()].substring( 0, 3 ); }, // A textual representation of a day, three letters
j : function( d ) { return d.getDate(); }, // Day of the month without leading zeros
l : function( d ) { return LOCALE.days[d.getDay()]; }, // A full textual representation of the day of the week
N : function( d ) { return d.ISODay(); }, // ISO-8601 numeric representation of the day of the week
S : function( d ) { return LOCALE.getOrdinal( d.getDate() ); }, // English ordinal suffix for the day of the month, 2 characters
w : function( d ) { return d.getDay(); }, // Numeric representation of the day of the week
z : function( d ) { return d.dayOfYear(); }, // The day of the year (starting from 0)
d : function( d ) { return pad( d.getDate(), 2 ); }, // Day of the month, 2 digits with leading zeros
D : function( d ) { return LOCALE.days[d.getDay()].substring( 0, 3 ); }, // A textual representation of a day, three letters
j : function( d ) { return d.getDate(); }, // Day of the month without leading zeros
l : function( d ) { return LOCALE.days[d.getDay()]; }, // A full textual representation of the day of the week
N : function( d ) { return d.ISODay(); }, // ISO-8601 numeric representation of the day of the week
S : function( d ) { return LOCALE.getOrdinal( d.getDate() ); }, // English ordinal suffix for the day of the month, 2 characters
w : function( d ) { return d.getDay(); }, // Numeric representation of the day of the week
z : function( d ) { return d.dayOfYear(); }, // The day of the year (starting from 0)
// week
W : function( d ) { return d.ISOWeek(); }, // ISO-8601 week number of year, weeks starting on Monday
W : function( d ) { return d.ISOWeek(); }, // ISO-8601 week number of year, weeks starting on Monday
// month
F : function( d ) { return LOCALE.months[d.getMonth()]; }, // A full textual representation of a month
m : function( d ) { return pad( ( d.getMonth() + 1 ), 2 ); }, // Numeric representation of a month, with leading zeros
M : function( d ) { return LOCALE.months[d.getMonth()].substring( 0, 3 ); }, // A short textual representation of a month, three letters
n : function( d ) { return d.getMonth() + 1; }, // Numeric representation of a month, without leading zeros
F : function( d ) { return LOCALE.months[d.getMonth()]; }, // A full textual representation of a month
m : function( d ) { return pad( ( d.getMonth() + 1 ), 2 ); }, // Numeric representation of a month, with leading zeros
M : function( d ) { return LOCALE.months[d.getMonth()].substring( 0, 3 ); }, // A short textual representation of a month, three letters
n : function( d ) { return d.getMonth() + 1; }, // Numeric representation of a month, without leading zeros
t : function( d ) { LOCALE.setLeapYear( d ); return LOCALE.day_count[d.getMonth()]; }, // Number of days in the given month
// year
L : function( d ) { return ( d.isLeapYear() ) ? 1 : 0; }, // Whether it's a leap year
o : function( d ) { // ISO-8601 year number. This has the same value as Y, except that if the ISO
var m = d.getMonth(), w = d.ISOWeek(); // week number (W) belongs to the previous or next year, that year is used instead.
L : function( d ) { return ( d.isLeapYear() ) ? 1 : 0; }, // Whether it's a leap year
o : function( d ) { // ISO-8601 year number. This has the same value as Y, except that if the ISO
var m = d.getMonth(), w = d.ISOWeek(); // week number (W) belongs to the previous or next year, that year is used instead.
return ( d.getFullYear() + ( w == 1 && m > 0 ? 1 : ( w >= 52 && m < 11 ? -1 : 0 ) ) );
},
Y : function( d ) { return d.getFullYear(); }, // A full numeric representation of a year, 4 digits
y : function( d ) { return String( d.getFullYear() ).substring( 2, 4 ); }, // A two digit representation of a year
Y : function( d ) { return d.getFullYear(); }, // A full numeric representation of a year, 4 digits
y : function( d ) { return String( d.getFullYear() ).substring( 2, 4 ); }, // A two digit representation of a year
// time
a : function( d ) { return _lc( d.getHours() < 12 ? LOCALE.AM : LOCALE.PM ); }, // Lowercase Ante meridiem and Post meridiem
A : function( d ) { return _uc( d.getHours() < 12 ? LOCALE.AM : LOCALE.PM ); }, // Uppercase Ante meridiem and Post meridiem
g : function( d ) { return d.getHours() % 12 || 12; }, // 12-hour format of an hour without leading zeros
G : function( d ) { return d.getHours(); }, // 24-hour format of an hour without leading zeros
h : function( d ) { return pad( filter.g( d ), 2 ); }, // 12-hour format of an hour with leading zeros
H : function( d ) { return pad( filter.G( d ), 2 ); }, // 24-hour format of an hour with leading zeros
i : function( d ) { return pad( d.getMinutes(), 2 ); }, // Minutes with leading zeros
s : function( d ) { return pad( d.getSeconds(), 2 ); }, // Seconds, with leading zeros
u : function( d ) { return pad( d.getMilliseconds(), 3 ); }, // Milliseconds
a : function( d ) { return _lc( d.getHours() < 12 ? LOCALE.AM : LOCALE.PM ); }, // Lowercase Ante meridiem and Post meridiem
A : function( d ) { return _uc( d.getHours() < 12 ? LOCALE.AM : LOCALE.PM ); }, // Uppercase Ante meridiem and Post meridiem
g : function( d ) { return d.getHours() % 12 || 12; }, // 12-hour format of an hour without leading zeros
G : function( d ) { return d.getHours(); }, // 24-hour format of an hour without leading zeros
h : function( d ) { return pad( filter.g( d ), 2 ); }, // 12-hour format of an hour with leading zeros
H : function( d ) { return pad( filter.G( d ), 2 ); }, // 24-hour format of an hour with leading zeros
i : function( d ) { return pad( d.getMinutes(), 2 ); }, // Minutes with leading zeros
s : function( d ) { return pad( d.getSeconds(), 2 ); }, // Seconds, with leading zeros
u : function( d ) { return pad( d.getMilliseconds(), 3 ); }, // Milliseconds
// timezone
O : function( d ) { return d.GMTOffset(); }, // Difference to Greenwich time (GMT) in hours
P : function( d ) { return d.GMTOffset( T ); }, // Difference to Greenwich time (GMT) with colon between hours and minutes
T : function( d ) { return d[TIMEZONE](); }, // Timezone abbreviation
Z : function( d ) { return d.getTimezoneOffset() * -60; }, // Timezone offset in seconds. The offset for timezones west of UTC
// is always negative, and for those east of UTC is always positive.
O : function( d ) { return d.GMTOffset(); }, // Difference to Greenwich time (GMT) in hours
P : function( d ) { return d.GMTOffset( T ); }, // Difference to Greenwich time (GMT) with colon between hours and minutes
T : function( d ) { return d[TIMEZONE](); }, // Timezone abbreviation
Z : function( d ) { return d.getTimezoneOffset() * -60; }, // Timezone offset in seconds. The offset for timezones west of UTC
// is always negative, and for those east of UTC is always positive.
// full date/time
c : function( d ) { return format( d, formats.ISO_8601 ); }, // ISO 8601 date
r : function( d ) { return format( d, formats.RFC_2822 ); }, // RFC 2822 formatted date
U : function( d ) { return d.getTime(); } // Seconds since the Unix Epoch January 1 1970 00:00:00 GMT
c : function( d ) { return format( d, formats.ISO_8601 ); }, // ISO 8601 date
r : function( d ) { return format( d, formats.RFC_2822 ); }, // RFC 2822 formatted date
U : function( d ) { return d.getTime(); } // Seconds since the Unix Epoch January 1 1970 00:00:00 GMT
};

date_chars = Object.keys( filter ).sort().join( '' );
Expand Down
Loading

0 comments on commit 9ebdfab

Please sign in to comment.