@@ -379,6 +379,14 @@ describe('datetimepicker', function() {
379
379
expect ( $ . timepicker . timezoneOffsetString ( - 720 , true ) ) . toBe ( '-12:00' ) ;
380
380
expect ( $ . timepicker . timezoneOffsetString ( 840 , true ) ) . toBe ( '+14:00' ) ;
381
381
} ) ;
382
+
383
+ it ( 'handles abnormal values reasonably' , function ( ) {
384
+ expect ( $ . timepicker . timezoneOffsetString ( null , false ) ) . toBe ( '+0000' ) ;
385
+ expect ( $ . timepicker . timezoneOffsetString ( null , true ) ) . toBe ( 'Z' ) ;
386
+
387
+ expect ( $ . timepicker . timezoneOffsetString ( undefined , false ) ) . toBeUndefined ( ) ;
388
+ expect ( $ . timepicker . timezoneOffsetString ( undefined , true ) ) . toBeUndefined ( ) ;
389
+ } ) ;
382
390
} ) ;
383
391
384
392
describe ( 'timezoneAdjust' , function ( ) {
@@ -557,7 +565,31 @@ describe('datetimepicker', function() {
557
565
} ) ;
558
566
559
567
describe ( 'timezone' , function ( ) {
560
- // TODO: Finish
568
+ var nullTimezoneTime = { timezone : null } ,
569
+ noTimezoneTime = emptyTime ,
570
+ timezoneTime = { timezone : - 240 } ,
571
+ noTimezoneOptions = { } ,
572
+ timezoneOptions = { timezone : 600 } ;
573
+
574
+ it ( 'handles z correctly' , function ( ) {
575
+ expect ( $ . datepicker . formatTime ( 'z' , timezoneTime , noTimezoneOptions ) ) . toBe ( '-0400' ) ;
576
+ expect ( $ . datepicker . formatTime ( 'z' , timezoneTime , timezoneOptions ) ) . toBe ( '-0400' ) ;
577
+
578
+ expect ( $ . datepicker . formatTime ( 'z' , nullTimezoneTime , timezoneOptions ) ) . toBe ( '+1000' ) ;
579
+ expect ( $ . datepicker . formatTime ( 'z' , noTimezoneTime , timezoneOptions ) ) . toBe ( '+1000' ) ;
580
+ expect ( $ . datepicker . formatTime ( 'z' , nullTimezoneTime , noTimezoneOptions ) ) . toBe ( '+0000' ) ;
581
+ expect ( $ . datepicker . formatTime ( 'z' , noTimezoneTime , noTimezoneOptions ) ) . toBe ( '+0000' ) ;
582
+ } ) ;
583
+
584
+ it ( 'handles Z correctly' , function ( ) {
585
+ expect ( $ . datepicker . formatTime ( 'Z' , timezoneTime , noTimezoneOptions ) ) . toBe ( '-04:00' ) ;
586
+ expect ( $ . datepicker . formatTime ( 'Z' , timezoneTime , timezoneOptions ) ) . toBe ( '-04:00' ) ;
587
+
588
+ expect ( $ . datepicker . formatTime ( 'Z' , nullTimezoneTime , timezoneOptions ) ) . toBe ( '+10:00' ) ;
589
+ expect ( $ . datepicker . formatTime ( 'Z' , noTimezoneTime , timezoneOptions ) ) . toBe ( '+10:00' ) ;
590
+ expect ( $ . datepicker . formatTime ( 'Z' , nullTimezoneTime , noTimezoneOptions ) ) . toBe ( 'Z' ) ;
591
+ expect ( $ . datepicker . formatTime ( 'Z' , noTimezoneTime , noTimezoneOptions ) ) . toBe ( 'Z' ) ;
592
+ } ) ;
561
593
} ) ;
562
594
563
595
describe ( 'am/pm' , function ( ) {
@@ -589,13 +621,19 @@ describe('datetimepicker', function() {
589
621
} ) ;
590
622
} ) ;
591
623
592
- describe ( 'other' , function ( ) {
593
- expect ( $ . datepicker . formatTime ( '' ) ) . toBe ( '' ) ;
594
- expect ( $ . datepicker . formatTime ( "'abc'" ) ) . toBe ( 'abc' ) ;
595
- expect ( $ . datepicker . formatTime ( '"abc"' ) ) . toBe ( '"abc"' ) ;
596
- expect ( $ . datepicker . formatTime ( "'" ) ) . toBe ( "'" ) ;
597
- expect ( $ . datepicker . formatTime ( "''" ) ) . toBe ( "" ) ;
598
- expect ( $ . datepicker . formatTime ( "'abc' h 'def'" ) ) . toBe ( 'abc 12 def' ) ;
624
+ describe ( 'literals' , function ( ) {
625
+ it ( 'handles literals correctly' , function ( ) {
626
+ expect ( $ . datepicker . formatTime ( '' , emptyTime ) ) . toBe ( '' ) ;
627
+ expect ( $ . datepicker . formatTime ( "'abc'" , emptyTime ) ) . toBe ( 'abc' ) ;
628
+ expect ( $ . datepicker . formatTime ( "'" , emptyTime ) ) . toBe ( "'" ) ;
629
+ expect ( $ . datepicker . formatTime ( "''" , emptyTime ) ) . toBe ( "" ) ;
630
+ expect ( $ . datepicker . formatTime ( "'abc' h 'def'" , emptyTime ) ) . toBe ( 'abc 12 def' ) ;
631
+ } ) ;
632
+
633
+ it ( 'does not treat double quotes as literals' , function ( ) {
634
+ expect ( $ . datepicker . formatTime ( '"ab"' , emptyTime ) ) . toBe ( '"ab"' ) ;
635
+ expect ( $ . datepicker . formatTime ( '"abc"' , emptyTime ) ) . toBe ( '"ab000"' ) ;
636
+ } ) ;
599
637
} ) ;
600
638
} ) ;
601
639
} ) ;
0 commit comments