forked from phstc/jquery-dateFormat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Test.html
executable file
·151 lines (141 loc) · 10.7 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
<!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>
<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() {
},
testFormatDateType1 : 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('18/12/2009 1: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 1:54:50 PM', $.format.date('2009-12-18 13:54:50.546', 'dd/MM/yyyy hh:mm:ss a'));
assertEqual('z18/b12/c2009 d10:e54:f50', $.format.date('2009-12-18 10:54:50.546', 'zdd/bMM/cyyyy dhh:emm:fss'));
assertEqual('2010', $.format.date(new Date(1274370756526), 'yyyy'));
}},
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 1: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 5:43:41 PM', $.format.date('Wed Jan 13 17:43:41 CET 2010', 'dd/MM/yyyy hh:mm:ss a'));
assertEqual('z13/b01/c2010 d10:e43:f41', $.format.date('Wed Jan 13 10:43:41 CET 2010', 'zdd/bMM/cyyyy dhh:emm:fss'));
}},
testFormatDateType3 : 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 1: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 5:43:41 PM', $.format.date('2010-10-19T17:43:41.527+02:00', 'dd/MM/yyyy hh:mm:ss a'));
assertEqual('z19/b10/c2010 d11:e40:f33', $.format.date('2010-10-19T11:40:33.527+02:00', 'zdd/bMM/cyyyy dhh:emm:fss'));
}},
testFormatDateType4: 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 1: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 5:43:41 PM', $.format.date(new Date('10/19/2010 17:43:41').toString(), 'dd/MM/yyyy hh:mm:ss a'));
assertEqual('z19/b10/c2010 d11:e40:f33', $.format.date(new Date('10/19/2010 11:40:33').toString(), 'zdd/bMM/cyyyy dhh:emm:fss'));
}},
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 1: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 7: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('z08/b04/c2011 d01:e02:f03', $.format.date('Fri Apr 08 2011 01:02:03 GMT+0800 (China Standard Time)', 'zdd/bMM/cyyyy dhh:emm:fss'));
}},
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 1: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 7: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('z08/b04/c2011 d01:e02:f03', $.format.date('Fri Apr 08 2011 01:02:03 GMT+0200 (W. Europe Daylight Time)', 'zdd/bMM/cyyyy dhh:emm:fss'));
}}
});
// ]]>
</script>
</body>
</html>