forked from lucee/Lucee
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJira2587.cfc
260 lines (219 loc) · 9.01 KB
/
Jira2587.cfc
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
<!---
*
* Copyright (c) 2014, the Railo Company LLC. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
---><cfscript>
component extends="org.lucee.cfml.test.LuceeTestCase" {
public function setUp(){
setTimeZone("CET");
date=createDateTime(2009,6,9,14,30,3);
}
public void function testA(){
// Am/pm marker
assertEquals("PM",DateTimeFormat(date,"a"));
assertEquals("PM",DateTimeFormat(date,"aa"));
assertEquals("PM",DateTimeFormat(date,"aaa"));
assertEquals("PM",DateTimeFormat(date,"aaaa"));
assertEquals("PM",DateTimeFormat(date,"aaaaa"));
assertEquals("A",DateTimeFormat(date,"A"));
}
public void function testD(){
// Day in month
assertEquals("9",DateTimeFormat(date,"d"));
assertEquals("09",DateTimeFormat(date,"dd"));
assertEquals("Tue",DateTimeFormat(date,"ddd"));
assertEquals("Tuesday",DateTimeFormat(date,"dddd"));
assertEquals("Tuesday",DateTimeFormat(date,"ddddd"));
// Day in year
assertEquals("160",DateTimeFormat(date,"D"));
assertEquals("160",DateTimeFormat(date,"DD"));
assertEquals("Tue",DateTimeFormat(date,"DDD"));
assertEquals("Tuesday",DateTimeFormat(date,"DDDD"));
assertEquals("Tuesday",DateTimeFormat(date,"DDDDD"));
}
public void function testE(){
// Day of week
assertEquals("Tue",DateTimeFormat(date,"E"));
assertEquals("Tue",DateTimeFormat(date,"EE"));
assertEquals("Tue",DateTimeFormat(date,"EEE"));
assertEquals("Tuesday",DateTimeFormat(date,"EEEE"));
assertEquals("Tuesday",DateTimeFormat(date,"EEEEE"));
assertEquals("e",DateTimeFormat(date,"e"));
}
public void function testF(){
// Day of week in month
assertEquals("2",DateTimeFormat(date,"F"));
assertEquals("02",DateTimeFormat(date,"FF"));
assertEquals("002",DateTimeFormat(date,"FFF"));
assertEquals("0002",DateTimeFormat(date,"FFFF"));
assertEquals("00002",DateTimeFormat(date,"FFFFF"));
assertEquals("f",DateTimeFormat(date,"f"));
}
public void function testG(){
// Era designator
assertEquals("AD",DateTimeFormat(date,"G"));
assertEquals("AD",DateTimeFormat(date,"GG"));
assertEquals("AD",DateTimeFormat(date,"GGG"));
assertEquals("AD AD",DateTimeFormat(date,"GG GG"));
assertEquals("AD",DateTimeFormat(date,"g"));
assertEquals("AD",DateTimeFormat(date,"gg"));
}
public void function testH(){
// Hour in day (0-23)
assertEquals("14",DateTimeFormat(date,"H"));
assertEquals("14",DateTimeFormat(date,"HH"));
assertEquals("014",DateTimeFormat(date,"HHH"));
assertEquals("0014",DateTimeFormat(date,"HHHH"));
assertEquals("00014",DateTimeFormat(date,"HHHHH"));
// Hour in am/pm (1-12)
assertEquals("2",DateTimeFormat(date,"h"));
assertEquals("02",DateTimeFormat(date,"hh"));
assertEquals("002",DateTimeFormat(date,"hhh"));
assertEquals("0002",DateTimeFormat(date,"hhhh"));
assertEquals("00002",DateTimeFormat(date,"hhhhh"));
}
public void function testK(){
// Hour in day (1-24)
assertEquals("14",DateTimeFormat(date,"k"));
assertEquals("14",DateTimeFormat(date,"kk"));
assertEquals("014",DateTimeFormat(date,"kkk"));
assertEquals("0014",DateTimeFormat(date,"kkkk"));
assertEquals("00014",DateTimeFormat(date,"kkkkk"));
// Hour in am/pm (0-11)
assertEquals("2",DateTimeFormat(date,"K"));
assertEquals("02",DateTimeFormat(date,"KK"));
assertEquals("002",DateTimeFormat(date,"KKK"));
assertEquals("0002",DateTimeFormat(date,"KKKK"));
assertEquals("00002",DateTimeFormat(date,"KKKKK"));
}
public void function testL(){
// milli seconds
assertEquals("0",DateTimeFormat(date,"l"));
assertEquals("00",DateTimeFormat(date,"ll"));
assertEquals("000",DateTimeFormat(date,"lll"));
assertEquals("0000",DateTimeFormat(date,"llll"));
assertEquals("00000",DateTimeFormat(date,"lllll"));
assertEquals("0",DateTimeFormat(date,"L"));
assertEquals("00",DateTimeFormat(date,"LL"));
assertEquals("000",DateTimeFormat(date,"LLL"));
assertEquals("0000",DateTimeFormat(date,"LLLL"));
assertEquals("00000",DateTimeFormat(date,"LLLLL"));
}
public void function testM(){
// month
assertEquals("6",DateTimeFormat(date,"M"));
assertEquals("06",DateTimeFormat(date,"MM"));
assertEquals("Jun",DateTimeFormat(date,"MMM"));
assertEquals("June",DateTimeFormat(date,"MMMM"));
assertEquals("June",DateTimeFormat(date,"MMMMM"));
assertEquals("6",DateTimeFormat(date,"m"));
assertEquals("06",DateTimeFormat(date,"mm"));
assertEquals("Jun",DateTimeFormat(date,"mmm"));
assertEquals("June",DateTimeFormat(date,"mmmm"));
assertEquals("June",DateTimeFormat(date,"mmmmm"));
}
public void function testN(){
// MINUTES IN HOUR
assertEquals("30",DateTimeFormat(date,"n"));
assertEquals("30",DateTimeFormat(date,"nn"));
assertEquals("030",DateTimeFormat(date,"nnn"));
assertEquals("0030",DateTimeFormat(date,"nnnn"));
assertEquals("00030",DateTimeFormat(date,"nnnnn"));
assertEquals("30",DateTimeFormat(date,"N"));
assertEquals("30",DateTimeFormat(date,"NN"));
assertEquals("030",DateTimeFormat(date,"NNN"));
assertEquals("0030",DateTimeFormat(date,"NNNN"));
assertEquals("00030",DateTimeFormat(date,"NNNNN"));
}
public void function testS(){
// Second in minute
assertEquals("3",DateTimeFormat(date,"s"));
assertEquals("03",DateTimeFormat(date,"ss"));
assertEquals("003",DateTimeFormat(date,"sss"));
assertEquals("0003",DateTimeFormat(date,"ssss"));
assertEquals("00003",DateTimeFormat(date,"sssss"));
assertEquals("3",DateTimeFormat(date,"S"));
assertEquals("03",DateTimeFormat(date,"SS"));
assertEquals("003",DateTimeFormat(date,"SSS"));
assertEquals("0003",DateTimeFormat(date,"SSSS"));
assertEquals("00003",DateTimeFormat(date,"SSSSS"));
}
public void function testT(){
//
assertEquals("P",DateTimeFormat(date,"t"));
assertEquals("PM",DateTimeFormat(date,"tt"));
assertEquals("PM",DateTimeFormat(date,"ttt"));
assertEquals("PM",DateTimeFormat(date,"tttt"));
assertEquals("PM",DateTimeFormat(date,"ttttt"));
assertEquals("P",DateTimeFormat(date,"T"));
assertEquals("PM",DateTimeFormat(date,"TT"));
assertEquals("PM",DateTimeFormat(date,"TTT"));
assertEquals("PM",DateTimeFormat(date,"TTTT"));
assertEquals("PM",DateTimeFormat(date,"TTTTT"));
}
public void function testW(){
// Week in year
assertEquals("24",DateTimeFormat(date,"w"));
assertEquals("24",DateTimeFormat(date,"ww"));
assertEquals("024",DateTimeFormat(date,"www"));
assertEquals("0024",DateTimeFormat(date,"wwww"));
assertEquals("00024",DateTimeFormat(date,"wwwww"));
// Week in month
assertEquals("2",DateTimeFormat(date,"W"));
assertEquals("02",DateTimeFormat(date,"WW"));
assertEquals("002",DateTimeFormat(date,"WWW"));
assertEquals("0002",DateTimeFormat(date,"WWWW"));
assertEquals("00002",DateTimeFormat(date,"WWWWW"));
}
public void function testY(){
// year
assertEquals("2009",DateTimeFormat(date,"y"));
assertEquals("09",DateTimeFormat(date,"yy"));
assertEquals("2009",DateTimeFormat(date,"yyy"));
assertEquals("2009",DateTimeFormat(date,"yyyy"));
assertEquals("02009",DateTimeFormat(date,"yyyyy"));
assertEquals("2009",DateTimeFormat(date,"Y"));
assertEquals("09",DateTimeFormat(date,"YY"));
assertEquals("2009",DateTimeFormat(date,"YYY"));
assertEquals("2009",DateTimeFormat(date,"YYYY"));
assertEquals("02009",DateTimeFormat(date,"YYYYY"));
}
public void function testZ(){
// Second in minute
assertEquals("CEST",DateTimeFormat(date,"z"));
assertEquals("CEST",DateTimeFormat(date,"zz"));
assertEquals("CEST",DateTimeFormat(date,"zzz"));
assertEquals("Central European Summer Time",DateTimeFormat(date,"zzzz"));
assertEquals("Central European Summer Time",DateTimeFormat(date,"zzzzz"));
assertEquals("+0200",DateTimeFormat(date,"Z"));
assertEquals("+0200",DateTimeFormat(date,"ZZ"));
assertEquals("+0200",DateTimeFormat(date,"ZZZ"));
assertEquals("+0200",DateTimeFormat(date,"ZZZZ"));
assertEquals("+0200",DateTimeFormat(date,"ZZZZZ"));
}
public void function testPredefined(){
assertEquals("6/9/09 2:30 PM",DateTimeFormat(date,"short"));
assertEquals("Jun 9, 2009 2:30:03 PM",DateTimeFormat(date,"medium"));
assertEquals("June 9, 2009 2:30:03 PM CEST",DateTimeFormat(date,"long"));
assertEquals("Tuesday, June 9, 2009 2:30:03 PM CEST",DateTimeFormat(date,"full"));
assertEquals("09-Jun-2009 14:30:03",DateTimeFormat(date));
}
public void function testSpecialCharacter(){
assertEquals("'",DateTimeFormat(date,"''"));
assertEquals("3 t 3",DateTimeFormat(date,"s 't' s"));
}
}
</cfscript>