@@ -17,11 +17,8 @@ function testFormat(name, dateObj, format, expected) {
17
17
} ) ;
18
18
}
19
19
20
- function suite ( name , suiteBody ) {
21
- suiteBody ( ) ;
22
- }
23
-
24
20
testParse ( 'basic date parse' , '2012/05/03' , 'YYYY/MM/DD' , new Date ( 2012 , 4 , 3 ) ) ;
21
+ testParse ( 'compact basic date parse' , '20120503' , 'YYYYMMDD' , new Date ( 2012 , 4 , 3 ) ) ;
25
22
testParse ( 'basic date parse with time' , '2012/05/03 05:01:40' , 'YYYY/MM/DD HH:mm:ss' , new Date ( 2012 , 4 , 3 , 5 , 1 , 40 ) ) ;
26
23
testParse ( 'date with different slashes' , '2012-05-03 05:01:40' , 'YYYY-MM-DD HH:mm:ss' , new Date ( 2012 , 4 , 3 , 5 , 1 , 40 ) ) ;
27
24
testParse ( 'date with different order' , '11-7-97' , 'D-M-YY' , new Date ( 1997 , 6 , 11 ) ) ;
@@ -168,6 +165,7 @@ testFormat('D-M-YYYY', new Date(2043, 8, 18, 2, 1, 9, 5), 'D-M-YYYY', '18-9-2043
168
165
testFormat ( 'current date' , new Date ( ) , 'YYYY' , '' + ( new Date ( ) ) . getFullYear ( ) ) ;
169
166
testFormat ( 'mask' , new Date ( 1999 , 0 , 2 ) , 'mediumDate' , 'Jan 2, 1999' ) ;
170
167
testFormat ( 'number date' , 1325376000000 , 'YYY-MM-DD HH:mm:ss' , fecha . format ( new Date ( Date . UTC ( 2012 , 0 , 1 ) ) , 'YYY-MM-DD HH:mm:ss' ) ) ;
168
+ testFormat ( 'compact date format' , new Date ( 2012 , 4 , 3 ) , 'YYYYMMDD' , '20120503' ) ;
171
169
test ( 'i18n am format' , function ( ) {
172
170
assert . equal ( fecha . format ( new Date ( 2018 , 4 , 2 , 10 ) , 'YYYY-MM-DD HHA' , {
173
171
amPm : [ 'sd' , 'gd' ] ,
@@ -179,18 +177,15 @@ test('no format', function() {
179
177
} ) ;
180
178
181
179
// Literals
182
- suite ( 'literals' , function ( ) {
183
- var date = new Date ( 2009 , 1 , 14 , 15 , 25 , 50 , 125 ) ;
184
-
185
- testFormat ( 'literal in format' , date , '[on] MM-DD-YYYY [at] HH:mm' ,
186
- 'on 02-14-2009 at 15:25' ) ;
187
- testFormat ( 'one literal' , date , '[day]' , 'day' ) ;
188
- testFormat ( 'two literals' , date , '[day] YY [YY]' , 'day 09 YY' ) ;
189
- testFormat ( 'incomplete literal' , date , '[YY' , '[09' ) ;
190
- testFormat ( 'literal inside literal' , date , '[[YY]]' , '[YY]' ) ;
191
- testFormat ( 'bracket inside literal' , date , '[[]' , '[' ) ;
192
- testFormat ( 'new lines' , date , 'YYYY[\n]DD[\n]' , '2009\n14\n' ) ;
193
- } ) ;
180
+ var date = new Date ( 2009 , 1 , 14 , 15 , 25 , 50 , 125 ) ;
181
+
182
+ testFormat ( 'literal in format' , date , '[on] MM-DD-YYYY [at] HH:mm' , 'on 02-14-2009 at 15:25' ) ;
183
+ testFormat ( 'one literal' , date , '[day]' , 'day' ) ;
184
+ testFormat ( 'two literals' , date , '[day] YY [YY]' , 'day 09 YY' ) ;
185
+ testFormat ( 'incomplete literal' , date , '[YY' , '[09' ) ;
186
+ testFormat ( 'literal inside literal' , date , '[[YY]]' , '[YY]' ) ;
187
+ testFormat ( 'bracket inside literal' , date , '[[]' , '[' ) ;
188
+ testFormat ( 'new lines' , date , 'YYYY[\n]DD[\n]' , '2009\n14\n' ) ;
194
189
195
190
test ( 'Invalid date' , function ( ) {
196
191
assert . throws ( function ( ) {
0 commit comments