forked from phstc/jquery-dateFormat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTest.html
executable file
·412 lines (401 loc) · 27.9 KB
/
Test.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>JavaScript unit test file</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script src="assets/jsunittest.js" type="text/javascript"></script>
<script src="jquery-1.4.min.js" type="text/javascript"></script>
<script src="jquery.dateFormat-1.0.js" type="text/javascript"></script>
<script src="document-ready-integration.js" type="text/javascript"></script>
<link rel="stylesheet" href="assets/unittest.css" type="text/css" />
</head>
<body>
<div id="content">
<div id="header">
<h1>JavaScript unit test file</h1>
</div>
<!-- Log output (one per Runner, via {testLog: "testlog"} option)-->
<div id="testlog"></div>
<!-- Put sample/test html here -->
<div id="sample">
</div>
</div>
<script type="text/javascript"><!--
// <![CDATA[
new Test.Unit.Runner({
setup: function() {
},
teardown: function() {
},
testISO8601Format : function() { with(this) {
var jsonDate = "2009-12-18T10:54:50Z";
assertEqual('18/12/2009', $.format.date(jsonDate, 'dd/MM/yyyy'));
assertEqual('Dec/2009', $.format.date(jsonDate, 'MMM/yyyy'));
assertEqual('12', $.format.date(jsonDate, 'MM'));
assertEqual('18', $.format.date(jsonDate, 'dd'));
assertEqual('2009', $.format.date(jsonDate, 'yyyy'));
assertEqual('12', $.format.date(jsonDate, 'MM'));
assertEqual('10:54:50', $.format.date(jsonDate, 'hh:mm:ss'));
assertEqual('10', $.format.date(jsonDate, 'hh'));
assertEqual('54', $.format.date(jsonDate, 'mm'));
assertEqual('50', $.format.date(jsonDate, 'ss'));
assertEqual('18/12/2009 10:54:50 AM', $.format.date(jsonDate, 'dd/MM/yyyy hh:mm:ss a'));
assertEqual('18/12/2009 10:54:50 a.m.', $.format.date(jsonDate, 'dd/MM/yyyy hh:mm:ss p'));
assertEqual('z18/b12/c2009 x10:e54:f50', $.format.date(jsonDate, 'zdd/bMM/cyyyy xhh:emm:fss'));
var jsonDate = "2009-12-18T13:54:50Z";
assertEqual('18/12/2009 01:54:50', $.format.date(jsonDate, 'dd/MM/yyyy hh:mm:ss'));
assertEqual('18/12/2009 13:54:50', $.format.date(jsonDate, 'dd/MM/yyyy HH:mm:ss'));
assertEqual('18/12/2009 01:54:50 PM', $.format.date(jsonDate, 'dd/MM/yyyy hh:mm:ss a'));
assertEqual('18/12/2009 01:54:50 p.m.', $.format.date(jsonDate, 'dd/MM/yyyy hh:mm:ss p'));
}},
testJavaUtilDateFormat : function() { with(this) {
/* Java java.util.Date output */
assertEqual('18/12/2009', $.format.date('2009-12-18 10:54:50.546', 'dd/MM/yyyy'));
assertEqual('Dec/2009', $.format.date('2009-12-18 10:54:50.546', 'MMM/yyyy'));
assertEqual('12', $.format.date('2009-12-18 10:54:50.546', 'MM'));
assertEqual('05', $.format.date('2009-12-5 10:54:50.546', 'dd'));
assertEqual('2009', $.format.date('2009-12-18 10:54:50.546', 'yyyy'));
assertEqual('12', $.format.date('2009-12-18 10:54:50.546', 'MM'));
assertEqual('10:54:50', $.format.date('2009-12-18 10:54:50.546', 'hh:mm:ss'));
assertEqual('10', $.format.date('2009-12-18 10:54:50.546', 'hh'));
assertEqual('54', $.format.date('2009-12-18 10:54:50.546', 'mm'));
assertEqual('50', $.format.date('2009-12-18 10:54:50.546', 'ss'));
assertEqual('546', $.format.date('2009-12-18 10:54:50.546', 'SSS'));
assertEqual('18/12/2009 01:54:50', $.format.date('2009-12-18 13:54:50.546', 'dd/MM/yyyy hh:mm:ss'));
assertEqual('18/12/2009 14:54:50', $.format.date('2009-12-18 14:54:50.546', 'dd/MM/yyyy HH:mm:ss'));
assertEqual('18/12/2009 10:54:50 AM', $.format.date('2009-12-18 10:54:50.546', 'dd/MM/yyyy hh:mm:ss a'));
assertEqual('18/12/2009 10:54:50 a.m.', $.format.date('2009-12-18 10:54:50.546', 'dd/MM/yyyy hh:mm:ss p'));
assertEqual('18/12/2009 01:54:50 PM', $.format.date('2009-12-18 13:54:50.546', 'dd/MM/yyyy hh:mm:ss a'));
assertEqual('18/12/2009 01:54:50 p.m.', $.format.date('2009-12-18 13:54:50.546', 'dd/MM/yyyy hh:mm:ss p'));
assertEqual('z18/b12/c2009 x10:e54:f50', $.format.date('2009-12-18 10:54:50.546', 'zdd/bMM/cyyyy xhh:emm:fss'));
assertEqual('2010', $.format.date(new Date(1274370756526), 'yyyy'));
assertEqual('Friday', $.format.date('2009-12-18 10:54:50.546', 'ddd'));
}},
testFormatDateType2 : function() { with(this) {
/* ??? Wed Jan 13 10:43:41 CET 2010 */
assertEqual('01/01/2010', $.format.date('Wed Jan 1 10:43:41 CET 2010', 'dd/MM/yyyy'));
assertEqual('Jan/2010', $.format.date('Wed Jan 13 10:43:41 CET 2010', 'MMM/yyyy'));
assertEqual('01', $.format.date('Wed Jan 13 10:43:41 CET 2010', 'MM'));
assertEqual('05', $.format.date('Wed Jan 5 10:43:41 CET 2010', 'dd'));
assertEqual('2010', $.format.date('Wed Jan 13 10:43:41 CET 2010', 'yyyy'));
assertEqual('01', $.format.date('Wed Jan 13 10:43:41 CET 2010', 'MM'));
assertEqual('10:43:41', $.format.date('Wed Jan 13 10:43:41 CET 2010', 'hh:mm:ss'));
assertEqual('10', $.format.date('Wed Jan 13 10:43:41 CET 2010', 'hh'));
assertEqual('43', $.format.date('Wed Jan 13 10:43:41 CET 2010', 'mm'));
assertEqual('41', $.format.date('Wed Jan 13 10:43:41 CET 2010', 'ss'));
assertEqual('13/01/2010 01:43:41', $.format.date('Wed Jan 13 13:43:41 CET 2010', 'dd/MM/yyyy hh:mm:ss'));
assertEqual('13/01/2010 14:43:41', $.format.date('Wed Jan 13 14:43:41 CET 2010', 'dd/MM/yyyy HH:mm:ss'));
assertEqual('13/01/2010 10:43:41 AM', $.format.date('Wed Jan 13 10:43:41 CET 2010', 'dd/MM/yyyy hh:mm:ss a'));
assertEqual('13/01/2010 10:43:41 a.m.', $.format.date('Wed Jan 13 10:43:41 CET 2010', 'dd/MM/yyyy hh:mm:ss p'));
assertEqual('13/01/2010 05:43:41 PM', $.format.date('Wed Jan 13 17:43:41 CET 2010', 'dd/MM/yyyy hh:mm:ss a'));
assertEqual('13/01/2010 05:43:41 p.m.', $.format.date('Wed Jan 13 17:43:41 CET 2010', 'dd/MM/yyyy hh:mm:ss p'));
assertEqual('z13/b01/c2010 x10:e43:f41', $.format.date('Wed Jan 13 10:43:41 CET 2010', 'zdd/bMM/cyyyy xhh:emm:fss'));
assertEqual('Wednesday', $.format.date('Wed Jan 13 10:43:41 CET 2010', 'ddd'));
}},
testJAXBFormat : function() { with(this) {
/* Java JAXB java.util.Date output */
assertEqual('19/10/2010', $.format.date('2010-10-19T11:40:33.527+02:00', 'dd/MM/yyyy'));
assertEqual('Oct/2010', $.format.date('2010-10-19T11:40:33.527+02:00', 'MMM/yyyy'));
assertEqual('10', $.format.date('2010-10-19T11:40:33.527+02:00', 'MM'));
assertEqual('05', $.format.date('2010-10-05T11:40:33.527+02:00', 'dd'));
assertEqual('2010', $.format.date('2010-10-19T11:40:33.527+02:00', 'yyyy'));
assertEqual('19', $.format.date('2010-10-19T11:40:33.527+02:00', 'dd'));
assertEqual('11:40:33', $.format.date('2010-10-19T11:40:33.527+02:00', 'hh:mm:ss'));
assertEqual('11', $.format.date('2010-10-19T11:40:33.527+02:00', 'hh'));
assertEqual('40', $.format.date('2010-10-19T11:40:33.527+02:00', 'mm'));
assertEqual('33', $.format.date('2010-10-19T11:40:33.527+02:00', 'ss'));
assertEqual('19/10/2010 01:43:41', $.format.date('2010-10-19T13:43:41.527+02:00', 'dd/MM/yyyy hh:mm:ss'));
assertEqual('19/10/2010 14:43:41', $.format.date('2010-10-19T14:43:41.527+02:000', 'dd/MM/yyyy HH:mm:ss'));
assertEqual('19/10/2010 10:43:41 AM', $.format.date('2010-10-19T10:43:41.527+02:00', 'dd/MM/yyyy hh:mm:ss a'));
assertEqual('19/10/2010 10:43:41 a.m.', $.format.date('2010-10-19T10:43:41.527+02:00', 'dd/MM/yyyy hh:mm:ss p'));
assertEqual('19/10/2010 05:43:41 PM', $.format.date('2010-10-19T17:43:41.527+02:00', 'dd/MM/yyyy hh:mm:ss a'));
assertEqual('19/10/2010 05:43:41 p.m.', $.format.date('2010-10-19T17:43:41.527+02:00', 'dd/MM/yyyy hh:mm:ss p'));
assertEqual('z19/b10/c2010 x11:e40:f33', $.format.date('2010-10-19T11:40:33.527+02:00', 'zdd/bMM/cyyyy xhh:emm:fss'));
assertEqual('Tuesday', $.format.date('2010-10-19T11:40:33.527+02:00', 'ddd'));
}},
testeJavaScriptDateFormat: function() { with(this) {
/* JavaScript Date output */
assertEqual('19/10/2010', $.format.date(new Date('10/19/2010 11:40:33').toString(), 'dd/MM/yyyy'));
assertEqual('Oct/2010', $.format.date(new Date('10/19/2010 11:40:33').toString(), 'MMM/yyyy'));
assertEqual('10', $.format.date(new Date('10/19/2010 11:40:33').toString(), 'MM'));
assertEqual('05', $.format.date(new Date('10/5/2010 11:40:33').toString(), 'dd'));
assertEqual('2010', $.format.date(new Date('10/19/2010 11:40:33').toString(), 'yyyy'));
assertEqual('19', $.format.date(new Date('10/19/2010 11:40:33').toString(), 'dd'));
assertEqual('11:40:33', $.format.date(new Date('10/19/2010 11:40:33').toString(), 'hh:mm:ss'));
assertEqual('11', $.format.date(new Date('10/19/2010 11:40:33').toString(), 'hh'));
assertEqual('40', $.format.date(new Date('10/19/2010 11:40:33').toString(), 'mm'));
assertEqual('33', $.format.date(new Date('10/19/2010 11:40:33').toString(), 'ss'));
assertEqual('19/10/2010 01:43:41', $.format.date(new Date('10/19/2010 13:43:41').toString(), 'dd/MM/yyyy hh:mm:ss'));
assertEqual('19/10/2010 14:43:41', $.format.date(new Date('10/19/2010 14:43:41').toString(), 'dd/MM/yyyy HH:mm:ss'));
assertEqual('19/10/2010 10:43:41 AM', $.format.date(new Date('10/19/2010 10:43:41').toString(), 'dd/MM/yyyy hh:mm:ss a'));
assertEqual('19/10/2010 10:43:41 a.m.', $.format.date(new Date('10/19/2010 10:43:41').toString(), 'dd/MM/yyyy hh:mm:ss p'));
assertEqual('19/10/2010 05:43:41 PM', $.format.date(new Date('10/19/2010 17:43:41').toString(), 'dd/MM/yyyy hh:mm:ss a'));
assertEqual('19/10/2010 05:43:41 p.m.', $.format.date(new Date('10/19/2010 17:43:41').toString(), 'dd/MM/yyyy hh:mm:ss p'));
assertEqual('z19/b10/c2010 x11:e40:f33', $.format.date(new Date('10/19/2010 11:40:33').toString(), 'zdd/bMM/cyyyy xhh:emm:fss'));
assertEqual('Tuesday', $.format.date(new Date('10/19/2010 10:43:41').toString(), 'ddd'));
}},
testFormatDateType5: function() { with(this) {
assertEqual('08/04/2011', $.format.date('Fri Apr 08 2011 01:02:03 GMT+0800 (China Standard Time)', 'dd/MM/yyyy'));
assertEqual('Apr/2011', $.format.date('Fri Apr 08 2011 01:02:03 GMT+0800 (China Standard Time)', 'MMM/yyyy'));
assertEqual('04', $.format.date('Fri Apr 08 2011 01:02:03 GMT+0800 (China Standard Time)', 'MM'));
assertEqual('08', $.format.date('Fri Apr 08 2011 01:02:03 GMT+0800 (China Standard Time)', 'dd'));
assertEqual('2011', $.format.date('Fri Apr 08 2011 01:02:03 GMT+0800 (China Standard Time)', 'yyyy'));
assertEqual('19', $.format.date('Fri Apr 19 2011 01:02:03 GMT+0800 (China Standard Time)', 'dd'));
assertEqual('01:02:03', $.format.date('Fri Apr 08 2011 01:02:03 GMT+0800 (China Standard Time)', 'hh:mm:ss'));
assertEqual('01', $.format.date('Fri Apr 08 2011 01:02:03 GMT+0800 (China Standard Time)', 'hh'));
assertEqual('02', $.format.date('Fri Apr 08 2011 01:02:03 GMT+0800 (China Standard Time)', 'mm'));
assertEqual('03', $.format.date('Fri Apr 08 2011 01:02:03 GMT+0800 (China Standard Time)', 'ss'));
assertEqual('08/04/2011 01:02:03', $.format.date('Fri Apr 08 2011 13:02:03 GMT+0800 (China Standard Time)', 'dd/MM/yyyy hh:mm:ss'));
assertEqual('08/04/2011 14:02:03', $.format.date('Fri Apr 08 2011 14:02:03 GMT+0800 (China Standard Time)', 'dd/MM/yyyy HH:mm:ss'));
assertEqual('08/04/2011 01:02:03 AM', $.format.date('Fri Apr 08 2011 01:02:03 GMT+0800 (China Standard Time)', 'dd/MM/yyyy hh:mm:ss a'));
assertEqual('08/04/2011 01:02:03 a.m.', $.format.date('Fri Apr 08 2011 01:02:03 GMT+0800 (China Standard Time)', 'dd/MM/yyyy hh:mm:ss p'));
assertEqual('08/04/2011 07:02:03 PM', $.format.date('Fri Apr 08 2011 19:02:03 GMT+0800 (China Standard Time)', 'dd/MM/yyyy hh:mm:ss a'));
assertEqual('08/04/2011 07:02:03 p.m.', $.format.date('Fri Apr 08 2011 19:02:03 GMT+0800 (China Standard Time)', 'dd/MM/yyyy hh:mm:ss p'));
assertEqual('z08/b04/c2011 x01:e02:f03', $.format.date('Fri Apr 08 2011 01:02:03 GMT+0800 (China Standard Time)', 'zdd/bMM/cyyyy xhh:emm:fss'));
assertEqual('Friday', $.format.date('Fri Apr 08 2011 13:02:03 GMT+0800 (China Standard Time)', 'ddd'));
}},
testFormatDateType6: function() { with(this) {
assertEqual('08/04/2011', $.format.date('Fri Apr 08 2011 01:02:03 GMT+0200 (W. Europe Daylight Time)', 'dd/MM/yyyy'));
assertEqual('Apr/2011', $.format.date('Fri Apr 08 2011 01:02:03 GMT+0200 (W. Europe Daylight Time)', 'MMM/yyyy'));
assertEqual('04', $.format.date('Fri Apr 08 2011 01:02:03 GMT+0200 (W. Europe Daylight Time)', 'MM'));
assertEqual('08', $.format.date('Fri Apr 08 2011 01:02:03 GMT+0200 (W. Europe Daylight Time)', 'dd'));
assertEqual('2011', $.format.date('Fri Apr 08 2011 01:02:03 GMT+0200 (W. Europe Daylight Time)', 'yyyy'));
assertEqual('19', $.format.date('Fri Apr 19 2011 01:02:03 GMT+0800 (China Standard Time)', 'dd'));
assertEqual('01:02:03', $.format.date('Fri Apr 08 2011 01:02:03 GMT+0200 (W. Europe Daylight Time)', 'hh:mm:ss'));
assertEqual('01', $.format.date('Fri Apr 08 2011 01:02:03 GMT+0200 (W. Europe Daylight Time)', 'hh'));
assertEqual('02', $.format.date('Fri Apr 08 2011 01:02:03 GMT+0200 (W. Europe Daylight Time)', 'mm'));
assertEqual('03', $.format.date('Fri Apr 08 2011 01:02:03 GMT+0200 (W. Europe Daylight Time)', 'ss'));
assertEqual('08/04/2011 01:02:03', $.format.date('Fri Apr 08 2011 13:02:03 GMT+0200 (W. Europe Daylight Time)', 'dd/MM/yyyy hh:mm:ss'));
assertEqual('08/04/2011 14:02:03', $.format.date('Fri Apr 08 2011 14:02:03 GMT+0200 (W. Europe Daylight Time)', 'dd/MM/yyyy HH:mm:ss'));
assertEqual('08/04/2011 01:02:03 AM', $.format.date('Fri Apr 08 2011 01:02:03 GMT+0200 (W. Europe Daylight Time)', 'dd/MM/yyyy hh:mm:ss a'));
assertEqual('08/04/2011 01:02:03 a.m.', $.format.date('Fri Apr 08 2011 01:02:03 GMT+0200 (W. Europe Daylight Time)', 'dd/MM/yyyy hh:mm:ss p'));
assertEqual('08/04/2011 07:02:03 PM', $.format.date('Fri Apr 08 2011 19:02:03 GMT+0200 (W. Europe Daylight Time)', 'dd/MM/yyyy hh:mm:ss a'));
assertEqual('08/04/2011 07:02:03 p.m.', $.format.date('Fri Apr 08 2011 19:02:03 GMT+0200 (W. Europe Daylight Time)', 'dd/MM/yyyy hh:mm:ss p'));
assertEqual('z08/b04/c2011 x01:e02:f03', $.format.date('Fri Apr 08 2011 01:02:03 GMT+0200 (W. Europe Daylight Time)', 'zdd/bMM/cyyyy xhh:emm:fss'));
assertEqual('Friday', $.format.date('Fri Apr 08 2011 14:02:03 GMT+0200 (W. Europe Daylight Time)', 'ddd'));
}},
testFormatDateType7: function() { with(this) {
/* Reference: http://pablocantero.com/blog/2010/09/04/jquery-plugin-javascript-for-java-util-date-tostring-format/#comment-259520318 */
assertEqual('19/04/2009', $.format.date('2009-04-19T16:11:05-02:00', 'dd/MM/yyyy'));
assertEqual('Apr/2009', $.format.date('2009-04-19T16:11:05-02:00', 'MMM/yyyy'));
}},
testFormatDateType8: function() { with(this) {
/* Reference: http://pablocantero.com/blog/2010/09/04/jquery-plugin-javascript-for-java-util-date-tostring-format/#comment-178490699 */
assertEqual('05:45PM', $.format.date('Mon Mar 28 2011 17:45:00 GMT-0400 (Eastern Daylight Time)', 'hh:mma'));
assertEqual('05:45p.m.', $.format.date('Mon Mar 28 2011 17:45:00 GMT-0400 (Eastern Daylight Time)', 'hh:mmp'));
}},
testDayInWeek: function() { with(this) {
assertEqual('Monday', $.format.date('Mon Mar 28 2011 17:45:00 GMT-0400 (Eastern Daylight Time)', 'ddd'));
}},
testMonthInYear: function() { with(this) {
assertEqual('Mar', $.format.date('Mon Mar 28 2011 17:45:00 GMT-0400 (Eastern Daylight Time)', 'MMM'));
assertEqual('March', $.format.date('Mon Mar 28 2011 17:45:00 GMT-0400 (Eastern Daylight Time)', 'MMMM'));
}},
testLongMonth: function() { with(this) {
assertEqual('February', $.format.date('Mon Feb 28 2011 17:45:00 GMT-0400 (Eastern Daylight Time)', 'MMMM'));
}},
testShortYear: function() { with(this) {
assertEqual(11, $.format.date('Mon Feb 28 2011 17:45:00 GMT-0400 (Eastern Daylight Time)', 'yy'));
assertEqual(12, $.format.date('Mon Feb 28 20112 17:45:00 GMT-0400 (Eastern Daylight Time)', 'yy'));
assertEqual('13.01.10', $.format.date('Wed Jan 13 10:43:41 CET 2010', 'dd.MM.yy'));
}},
testShortHour: function() { with(this) {
assertEqual('5', $.format.date('Mon Feb 28 2011 17:45:00 GMT-0400 (Eastern Daylight Time)', 'h'));
assertEqual('5', $.format.date('Mon Feb 28 20112 17:45:00 GMT-0400 (Eastern Daylight Time)', 'h'));
assertEqual('13.01.10 10', $.format.date('Wed Jan 13 10:43:41 CET 2010', 'dd.MM.yy h'));
assertEqual('6', $.format.date('Wed Jan 25 06:23:38 PST 2012', 'h'));
assertEqual('06', $.format.date('Wed Jan 25 06:23:38 PST 2012', 'hh'));
assertEqual('5', $.format.date('Mon Feb 28 2011 17:45:00 GMT-0400 (Eastern Daylight Time)', 'h'));
assertEqual('5', $.format.date('Mon Feb 28 20112 17:45:00 GMT-0400 (Eastern Daylight Time)', 'h'));
assertEqual('13.01.10 10', $.format.date('Wed Jan 13 10:43:41 CET 2010', 'dd.MM.yy h'));
}},
testLongHour: function() { with(this) {
assertEqual('17', $.format.date('Mon Feb 28 2011 17:45:00 GMT-0400 (Eastern Daylight Time)', 'H'));
assertEqual('17', $.format.date('Mon Feb 28 20112 17:45:00 GMT-0400 (Eastern Daylight Time)', 'H'));
assertEqual('13.01.10 10', $.format.date('Wed Jan 13 10:43:41 CET 2010', 'dd.MM.yy H'));
assertEqual('6', $.format.date('Wed Jan 25 06:23:38 PST 2012', 'H'));
assertEqual('06', $.format.date('Wed Jan 25 06:23:38 PST 2012', 'HH'));
assertEqual('06', $.format.date('Wed Jan 25 6:23:38 PST 2012', 'HH'));
assertEqual('17', $.format.date('Mon Feb 28 2011 17:45:00 GMT-0400 (Eastern Daylight Time)', 'H'));
assertEqual('17', $.format.date('Mon Feb 28 20112 17:45:00 GMT-0400 (Eastern Daylight Time)', 'H'));
assertEqual('13.01.10 10', $.format.date('Wed Jan 13 10:43:41 CET 2010', 'dd.MM.yy H'));
}},
testIssue19: function() { with(this) {
assertEqual('Sep 29, 2011', $.format.date("2011-09-29 14:50:49", "MMM dd, yyyy"));
}},
testIssue17: function() { with(this) {
assertEqual('2011-04-25 09:04', $.format.date("2011-04-25T09:04:14.7270000", "yyyy-MM-dd HH:mm"));
}},
testShortDay: function() { with(this) {
assertEqual('January 9, 2012', $.format.date('Wed Jan 09 06:23:38 PST 2012', 'MMMM d, yyyy'));
assertEqual('January 09, 2012', $.format.date('Wed Jan 09 06:23:38 PST 2012', 'MMMM dd, yyyy'));
assertEqual('2012.1.9', $.format.date('Wed Jan 09 06:23:38 PST 2012', 'yyyy.M.d'));
assertEqual('1.9.2012', $.format.date('Wed Jan 09 06:23:38 PST 2012', 'M.d.yyyy'));
}},
testMinute: function() { with(this) {
assertEqual('3', $.format.date('Wed Jan 09 06:3:38 PST 2012', 'm'));
assertEqual('03', $.format.date('Wed Jan 09 06:3:38 PST 2012', 'mm'));
assertEqual('Apr 17 2013 10:08:01', $.format.date("2013-04-17 10:8:1", "MMM dd yyyy HH:mm:ss"));
}},
testSecond: function() { with(this) {
assertEqual('8', $.format.date('Wed Jan 09 06:3:8 PST 2012', 's'));
assertEqual('08', $.format.date('Wed Jan 09 06:3:8 PST 2012', 'ss'));
}},
testJapanese: function() { with(this) {
assertEqual('2012年01月09日', $.format.date('Wed Jan 09 06:23:38 PST 2012', 'yyyy年MM月dd日'));
}},
testIssue24: function() { with(this) {
assertEqual('-', $.format.date('Wed Jan 09 06:23:38 PST 2012', '-'));
assertEqual('9-', $.format.date('Wed Jan 09 06:23:38 PST 2012', 'd-'));
assertEqual('9/', $.format.date('Wed Jan 09 06:23:38 PST 2012', 'd/'));
}},
testPullRequest: function() { with(this) {
// https://github.com/phstc/jquery-dateFormat/pull/22
assertEqual('07/02/2012', $.format.date('2012-02-07CET00:00:00', 'dd/MM/yyyy'));
assertEqual('Feb/2012', $.format.date('2012-02-07CET00:00:00', 'MMM/yyyy'));
assertEqual('02', $.format.date('2012-02-07CET00:00:00', 'MM'));
assertEqual('07', $.format.date('2012-02-07CET00:00:00', 'dd'));
assertEqual('2012', $.format.date('2012-02-07CET00:00:00', 'yyyy'));
}},
testUnixTimeStamp: function() { with(this) {
// https://github.com/phstc/jquery-dateFormat/pull/22
var testDate = new Date("Jan 2, 2000 01:02:03");
assertEqual("01", $.format.date(testDate.getTime(), 'MM'));
assertEqual("2", $.format.date(testDate.getTime(), 'd'));
assertEqual("2000", $.format.date(testDate.getTime(), 'yyyy'));
assertEqual("01", $.format.date(testDate.getTime(), 'HH'));
assertEqual("02", $.format.date(testDate.getTime(), 'mm'));
assertEqual("03", $.format.date(testDate.getTime(), 'ss'));
}},
testeShortMonthNoPrependedZero: function() { with(this) {
var testDate = new Date("Jan 2, 2000 01:02:03");
assertEqual('2', $.format.date('Wed Feb 09 06:23:38 PST 2012', 'M'));
assertEqual("1", $.format.date(testDate.getTime(), 'M'));
assertEqual('5', $.format.date('2012-05-07CET00:00:00', 'M'));
}},
testeOrdinalDays: function() { with(this) {
assertEqual('1st', $.format.date(new Date("Jan 1, 2000 01:02:03"), 'D'));
assertEqual('2nd', $.format.date(new Date("Jan 2, 2000 01:02:03"), 'D'));
assertEqual('3rd', $.format.date(new Date("Jan 3, 2000 01:02:03"), 'D'));
assertEqual('4th', $.format.date(new Date("Jan 4, 2000 01:02:03"), 'D'));
assertEqual('5th', $.format.date(new Date("Jan 5, 2000 01:02:03"), 'D'));
assertEqual('6th', $.format.date(new Date("Jan 6, 2000 01:02:03"), 'D'));
assertEqual('7th', $.format.date(new Date("Jan 7, 2000 01:02:03"), 'D'));
assertEqual('8th', $.format.date(new Date("Jan 8, 2000 01:02:03"), 'D'));
assertEqual('9th', $.format.date(new Date("Jan 9, 2000 01:02:03"), 'D'));
assertEqual('10th', $.format.date(new Date("Jan 10, 2000 01:02:03"), 'D'));
assertEqual('11th', $.format.date(new Date("Jan 11, 2000 01:02:03"), 'D'));
assertEqual('12th', $.format.date(new Date("Jan 12, 2000 01:02:03"), 'D'));
assertEqual('13th', $.format.date(new Date("Jan 13, 2000 01:02:03"), 'D'));
assertEqual('14th', $.format.date(new Date("Jan 14, 2000 01:02:03"), 'D'));
assertEqual('15th', $.format.date(new Date("Jan 15, 2000 01:02:03"), 'D'));
assertEqual('16th', $.format.date(new Date("Jan 16, 2000 01:02:03"), 'D'));
assertEqual('17th', $.format.date(new Date("Jan 17, 2000 01:02:03"), 'D'));
assertEqual('18th', $.format.date(new Date("Jan 18, 2000 01:02:03"), 'D'));
assertEqual('19th', $.format.date(new Date("Jan 19, 2000 01:02:03"), 'D'));
assertEqual('20th', $.format.date(new Date("Jan 20, 2000 01:02:03"), 'D'));
assertEqual('21st', $.format.date(new Date("Jan 21, 2000 01:02:03"), 'D'));
assertEqual('22nd', $.format.date(new Date("Jan 22, 2000 01:02:03"), 'D'));
assertEqual('23rd', $.format.date(new Date("Jan 23, 2000 01:02:03"), 'D'));
assertEqual('24th', $.format.date(new Date("Jan 24, 2000 01:02:03"), 'D'));
assertEqual('25th', $.format.date(new Date("Jan 25, 2000 01:02:03"), 'D'));
assertEqual('26th', $.format.date(new Date("Jan 26, 2000 01:02:03"), 'D'));
assertEqual('27th', $.format.date(new Date("Jan 27, 2000 01:02:03"), 'D'));
assertEqual('28th', $.format.date(new Date("Jan 28, 2000 01:02:03"), 'D'));
assertEqual('29th', $.format.date(new Date("Jan 29, 2000 01:02:03"), 'D'));
assertEqual('30th', $.format.date(new Date("Jan 30, 2000 01:02:03"), 'D'));
assertEqual('31st', $.format.date(new Date("Jan 31, 2000 01:02:03"), 'D'));
}},
testDefaultLongDateFormat: function() { with(this) {
var longFormat = jQuery.format.date.defaultLongDateFormat;
assertEqual('01/01/2000 01:02:03', $.format.date(new Date("Jan 1, 2000 01:02:03"), longFormat));
assertEqual('19/10/2010 11:40:33', $.format.date(new Date('10/19/2010 11:40:33').toString(), longFormat));
assertEqual('28/03/2011 17:45:00', $.format.date('Mon Mar 28 2011 17:45:00 GMT-0400 (Eastern Daylight Time)', longFormat));
assertEqual('08/04/2011 19:02:03', $.format.date('Fri Apr 08 2011 19:02:03 GMT+0200 (W. Europe Daylight Time)', longFormat));
assertEqual('19/10/2010 11:40:33', $.format.date('2010-10-19T11:40:33.527+02:00', longFormat));
}},
testDefaultShortDateFormat: function() { with(this) {
var shortFormat = jQuery.format.date.defaultShortDateFormat;
assertEqual('01/01/2000', $.format.date(new Date("Jan 1, 2000 01:02:03"), shortFormat));
assertEqual('19/10/2010', $.format.date(new Date('10/19/2010 11:40:33').toString(), shortFormat));
assertEqual('28/03/2011', $.format.date('Mon Mar 28 2011 17:45:00 GMT-0400 (Eastern Daylight Time)', shortFormat));
assertEqual('08/04/2011', $.format.date('Fri Apr 08 2011 19:02:03 GMT+0200 (W. Europe Daylight Time)', shortFormat));
assertEqual('19/10/2010', $.format.date('2010-10-19T11:40:33.527+02:00', shortFormat));
}},
testToBrowserTimeZone: function() { with(this) {
var today = new Date();
assertEqual($.format.date(today, "MM/dd/yyyy"), $.format.toBrowserTimeZone(today, "MM/dd/yyyy"));
assertEqual($.format.date(today, "MM/dd/yyyy"), $.format.toBrowserTimeZone(today.toString(), "MM/dd/yyyy"));
}},
testPrettyDate: function() { with(this) {
var today = new Date();
var daysago1 = new Date();
var daysago6 = new Date();
var daysago7 = new Date();
var daysago8 = new Date();
var daysago13 = new Date();
var daysago14 = new Date();
var daysago15 = new Date();
var daysago20 = new Date();
var daysago21 = new Date();
var daysago22 = new Date();
var daysago27 = new Date();
var daysago28 = new Date();
var daysago29 = new Date();
var daysago30 = new Date();
var daysago31 = new Date();
var daysago100 = new Date();
var isoDateFormat = "2013-07-14T23:22:33Z";
var jaxbDateFormat = "2013-07-14T16:22:33.527-07:00";
var unixDateFormat = "Sat Jul 14 2013 16:22:33 GMT-0700 (PDT)";
daysago1.setDate(daysago1.getDate() -1);
daysago6.setDate(daysago6.getDate() -6);
daysago7.setDate(daysago7.getDate() -7);
daysago8.setDate(daysago8.getDate() -8);
daysago13.setDate(daysago13.getDate() -13);
daysago14.setDate(daysago14.getDate() -14);
daysago15.setDate(daysago15.getDate() -15);
daysago20.setDate(daysago20.getDate() -20);
daysago21.setDate(daysago21.getDate() -21);
daysago22.setDate(daysago22.getDate() -22);
daysago27.setDate(daysago27.getDate() -27);
daysago28.setDate(daysago28.getDate() -28);
daysago29.setDate(daysago29.getDate() -29);
daysago30.setDate(daysago30.getDate() -30);
daysago31.setDate(daysago31.getDate() -31);
daysago100.setDate(daysago100.getDate() -100);
assertEqual("just now", $.format.prettyDate(today));
assertEqual("just now", $.format.prettyDate(today.toString()));
assertEqual("just now", $.format.prettyDate(today.getTime()));
assertEqual("Yesterday", $.format.prettyDate(daysago1));
assertEqual("6 days ago", $.format.prettyDate(daysago6));
assertEqual("1 weeks ago", $.format.prettyDate(daysago7));
assertEqual("2 weeks ago", $.format.prettyDate(daysago8));
assertEqual("2 weeks ago", $.format.prettyDate(daysago13));
assertEqual("2 weeks ago", $.format.prettyDate(daysago14));
assertEqual("3 weeks ago", $.format.prettyDate(daysago15));
assertEqual("3 weeks ago", $.format.prettyDate(daysago20));
assertEqual("3 weeks ago", $.format.prettyDate(daysago21));
assertEqual("4 weeks ago", $.format.prettyDate(daysago27));
assertEqual("4 weeks ago", $.format.prettyDate(daysago28));
assertEqual("5 weeks ago", $.format.prettyDate(daysago29));
assertEqual("5 weeks ago", $.format.prettyDate(daysago30));
assertEqual("more than 5 weeks ago", $.format.prettyDate(daysago31));
assertEqual("more than 5 weeks ago", $.format.prettyDate(daysago100));
assertEqual("more than 5 weeks ago", $.format.prettyDate(isoDateFormat));
assertEqual("more than 5 weeks ago", $.format.prettyDate(jaxbDateFormat));
assertEqual("more than 5 weeks ago", $.format.prettyDate(unixDateFormat));
}},
testQuotedChars: function() { with(this) {
assertEqual('8 seconds', $.format.date('Wed Jan 09 06:3:8 PST 2012', "s 'seconds'"));
assertEqual('second: 8', $.format.date('Wed Jan 09 06:3:8 PST 2012', "'second:' s"));
assertEqual('3 sec 8', $.format.date('Wed Jan 09 06:3:8 PST 2012', "m 'sec' s"));
assertEqual("8'", $.format.date('Wed Jan 09 06:3:8 PST 2012', "s''"));
assertEqual("6 o'clock", $.format.date('Wed Jan 09 06:3:8 PST 2012', "h 'o''''clock'"));
}}
});
// ]]>
</script>
</body>
</html>