@@ -55,23 +55,23 @@ function date(format, timestamp) {
55
55
// example 9: date('W Y-m-d', 1293974054); // 2011-01-02
56
56
// returns 9: '52 2011-01-02'
57
57
58
- var that = this ,
59
- jsdate ,
60
- f ,
61
- // Keep this here (works, but for code commented-out
62
- // below for file size reasons)
63
- //, tal= [] ,
64
- txt_words = [ 'Sun ', 'Mon ' , 'Tues ' , 'Wednes ' , 'Thurs ' , 'Fri' , 'Satur' , 'January' , 'February' , 'March' , 'April ',
65
- 'May' , 'June' , 'July' , 'August' , 'September' , 'October' , 'November' , 'December'
66
- ] ,
67
- // trailing backslash -> (dropped)
68
- // a backslash followed by any character (including backslash) -> the character
69
- // empty string -> empty string
70
- formatChr = / \\ ? ( .? ) / gi,
71
- formatChrCb = function ( t , s ) {
72
- return f [ t ] ? f [ t ] ( ) : s ;
73
- } ;
74
- _pad = function ( n , c ) {
58
+ var that = this ;
59
+ var jsdate , f ;
60
+ // Keep this here (works, but for code commented-out below for file size reasons)
61
+ // var tal= [];
62
+ var txt_words = [
63
+ 'Sun' , 'Mon' , 'Tues' , 'Wednes' , 'Thurs' , 'Fri' , 'Satur' ,
64
+ 'January ', 'February ' , 'March ' , 'April ' , 'May ' , 'June ' ,
65
+ 'July' , 'August' , 'September' , 'October' , 'November' , 'December'
66
+ ] ;
67
+ // trailing backslash -> (dropped)
68
+ // a backslash followed by any character (including backslash) -> the character
69
+ // empty string -> empty string
70
+ var formatChr = / \\ ? ( .? ) / gi;
71
+ var formatChrCb = function ( t , s ) {
72
+ return f [ t ] ? f [ t ] ( ) : s ;
73
+ } ;
74
+ var _pad = function ( n , c ) {
75
75
n = String ( n ) ;
76
76
while ( n . length < c ) {
77
77
n = '0' + n ;
@@ -97,8 +97,8 @@ function date(format, timestamp) {
97
97
return f . w ( ) || 7 ;
98
98
} ,
99
99
S : function ( ) { // Ordinal suffix for day of month; st, nd, rd, th
100
- var j = f . j ( ) ,
101
- i = j % 10 ;
100
+ var j = f . j ( ) ;
101
+ var i = j % 10 ;
102
102
if ( i <= 3 && parseInt ( ( j % 100 ) / 10 , 10 ) == 1 ) {
103
103
i = 0 ;
104
104
}
@@ -108,15 +108,15 @@ function date(format, timestamp) {
108
108
return jsdate . getDay ( ) ;
109
109
} ,
110
110
z : function ( ) { // Day of year; 0..365
111
- var a = new Date ( f . Y ( ) , f . n ( ) - 1 , f . j ( ) ) ,
112
- b = new Date ( f . Y ( ) , 0 , 1 ) ;
111
+ var a = new Date ( f . Y ( ) , f . n ( ) - 1 , f . j ( ) ) ;
112
+ var b = new Date ( f . Y ( ) , 0 , 1 ) ;
113
113
return Math . round ( ( a - b ) / 864e5 ) ;
114
114
} ,
115
115
116
116
// Week
117
117
W : function ( ) { // ISO-8601 week number
118
- var a = new Date ( f . Y ( ) , f . n ( ) - 1 , f . j ( ) - f . N ( ) + 3 ) ,
119
- b = new Date ( a . getFullYear ( ) , 0 , 4 ) ;
118
+ var a = new Date ( f . Y ( ) , f . n ( ) - 1 , f . j ( ) - f . N ( ) + 3 ) ;
119
+ var b = new Date ( a . getFullYear ( ) , 0 , 4 ) ;
120
120
return _pad ( 1 + Math . round ( ( a - b ) / 864e5 / 7 ) , 2 ) ;
121
121
} ,
122
122
@@ -145,9 +145,9 @@ function date(format, timestamp) {
145
145
return j % 4 === 0 & j % 100 !== 0 | j % 400 === 0 ;
146
146
} ,
147
147
o : function ( ) { // ISO-8601 year
148
- var n = f . n ( ) ,
149
- W = f . W ( ) ,
150
- Y = f . Y ( ) ;
148
+ var n = f . n ( ) ;
149
+ var W = f . W ( ) ;
150
+ var Y = f . Y ( ) ;
151
151
return Y + ( n === 12 && W < 9 ? 1 : n === 1 && W > 9 ? - 1 : 0 ) ;
152
152
} ,
153
153
Y : function ( ) { // Full year; e.g. 1980...2010
@@ -168,11 +168,11 @@ function date(format, timestamp) {
168
168
. toUpperCase ( ) ;
169
169
} ,
170
170
B : function ( ) { // Swatch Internet time; 000..999
171
- var H = jsdate . getUTCHours ( ) * 36e2 ,
172
- // Hours
173
- i = jsdate . getUTCMinutes ( ) * 60 ,
174
- // Minutes
175
- s = jsdate . getUTCSeconds ( ) ; // Seconds
171
+ var H = jsdate . getUTCHours ( ) * 36e2 ;
172
+ // Hours
173
+ var i = jsdate . getUTCMinutes ( ) * 60 ;
174
+ // Minutes
175
+ var s = jsdate . getUTCSeconds ( ) ; // Seconds
176
176
return _pad ( Math . floor ( ( H + i + s + 36e2 ) / 86.4 ) % 1e3 , 3 ) ;
177
177
} ,
178
178
g : function ( ) { // 12-Hours; 1..12
@@ -208,18 +208,18 @@ function date(format, timestamp) {
208
208
I : function ( ) { // DST observed?; 0 or 1
209
209
// Compares Jan 1 minus Jan 1 UTC to Jul 1 minus Jul 1 UTC.
210
210
// If they are not equal, then DST is observed.
211
- var a = new Date ( f . Y ( ) , 0 ) ,
212
- // Jan 1
213
- c = Date . UTC ( f . Y ( ) , 0 ) ,
214
- // Jan 1 UTC
215
- b = new Date ( f . Y ( ) , 6 ) ,
216
- // Jul 1
217
- d = Date . UTC ( f . Y ( ) , 6 ) ; // Jul 1 UTC
211
+ var a = new Date ( f . Y ( ) , 0 ) ;
212
+ // Jan 1
213
+ var c = Date . UTC ( f . Y ( ) , 0 ) ;
214
+ // Jan 1 UTC
215
+ var b = new Date ( f . Y ( ) , 6 ) ;
216
+ // Jul 1
217
+ var d = Date . UTC ( f . Y ( ) , 6 ) ; // Jul 1 UTC
218
218
return ( ( a - c ) !== ( b - d ) ) ? 1 : 0 ;
219
219
} ,
220
220
O : function ( ) { // Difference to GMT in hour format; e.g. +0200
221
- var tzo = jsdate . getTimezoneOffset ( ) ,
222
- a = Math . abs ( tzo ) ;
221
+ var tzo = jsdate . getTimezoneOffset ( ) ;
222
+ var a = Math . abs ( tzo ) ;
223
223
return ( tzo > 0 ? '-' : '+' ) + _pad ( Math . floor ( a / 60 ) * 100 + a % 60 , 4 ) ;
224
224
} ,
225
225
P : function ( ) { // Difference to GMT w/colon; e.g. +02:00
@@ -229,15 +229,15 @@ function date(format, timestamp) {
229
229
T : function ( ) { // Timezone abbreviation; e.g. EST, MDT, ...
230
230
// The following works, but requires inclusion of the very
231
231
// large timezone_abbreviations_list() function.
232
- /* var abbr = '' , i = 0 , os = 0, default = 0 ;
232
+ /* var abbr, i, os, _default ;
233
233
if (!tal.length) {
234
234
tal = that.timezone_abbreviations_list();
235
235
}
236
236
if (that.php_js && that.php_js.default_timezone) {
237
- default = that.php_js.default_timezone;
237
+ _default = that.php_js.default_timezone;
238
238
for (abbr in tal) {
239
- for (i= 0; i < tal[abbr].length; i++) {
240
- if (tal[abbr][i].timezone_id === default ) {
239
+ for (i = 0; i < tal[abbr].length; i++) {
240
+ if (tal[abbr][i].timezone_id === _default ) {
241
241
return abbr.toUpperCase();
242
242
}
243
243
}
@@ -273,8 +273,8 @@ function date(format, timestamp) {
273
273
that = this ;
274
274
jsdate = ( timestamp === undefined ? new Date ( ) : // Not provided
275
275
( timestamp instanceof Date ) ? new Date ( timestamp ) : // JS Date()
276
- new Date ( timestamp * 1000 ) // UNIX timestamp (auto-convert to int)
277
- ) ;
276
+ new Date ( timestamp * 1000 ) // UNIX timestamp (auto-convert to int)
277
+ ) ;
278
278
return format . replace ( formatChr , formatChrCb ) ;
279
279
} ;
280
280
return this . date ( format , timestamp ) ;
0 commit comments