@@ -613,6 +613,19 @@ describe('input', function() {
613
613
} ) ;
614
614
615
615
616
+ it ( 'should use any timezone if specified in the options' , function ( ) {
617
+ var inputElm = helper . compileInput ( '<input type="month" ng-model="value" ng-model-options="{timezone: \'+0500\'}" />' ) ;
618
+
619
+ helper . changeInputValueTo ( '2013-07' ) ;
620
+ expect ( + $rootScope . value ) . toBe ( Date . UTC ( 2013 , 5 , 30 , 19 , 0 , 0 ) ) ;
621
+
622
+ $rootScope . $apply ( function ( ) {
623
+ $rootScope . value = new Date ( Date . UTC ( 2014 , 5 , 30 , 19 , 0 , 0 ) ) ;
624
+ } ) ;
625
+ expect ( inputElm . val ( ) ) . toBe ( '2014-07' ) ;
626
+ } ) ;
627
+
628
+
616
629
it ( 'should label parse errors as `month`' , function ( ) {
617
630
var inputElm = helper . compileInput ( '<input type="month" ng-model="val" name="alias" />' , {
618
631
valid : false ,
@@ -636,6 +649,17 @@ describe('input', function() {
636
649
expect ( inputElm . val ( ) ) . toBe ( '2013-12' ) ;
637
650
} ) ;
638
651
652
+ it ( 'should only change the month of a bound date in any timezone' , function ( ) {
653
+ var inputElm = helper . compileInput ( '<input type="month" ng-model="value" ng-model-options="{timezone: \'+0500\'}" />' ) ;
654
+
655
+ $rootScope . $apply ( function ( ) {
656
+ $rootScope . value = new Date ( Date . UTC ( 2013 , 6 , 31 , 20 , 0 , 0 ) ) ;
657
+ } ) ;
658
+ helper . changeInputValueTo ( '2013-09' ) ;
659
+ expect ( + $rootScope . value ) . toBe ( Date . UTC ( 2013 , 7 , 31 , 20 , 0 , 0 ) ) ;
660
+ expect ( inputElm . val ( ) ) . toBe ( '2013-09' ) ;
661
+ } ) ;
662
+
639
663
describe ( 'min' , function ( ) {
640
664
var inputElm ;
641
665
beforeEach ( function ( ) {
@@ -814,6 +838,19 @@ describe('input', function() {
814
838
} ) ;
815
839
816
840
841
+ it ( 'should use any timezone if specified in the options' , function ( ) {
842
+ var inputElm = helper . compileInput ( '<input type="week" ng-model="value" ng-model-options="{timezone: \'+0500\'}" />' ) ;
843
+
844
+ helper . changeInputValueTo ( '2013-W03' ) ;
845
+ expect ( + $rootScope . value ) . toBe ( Date . UTC ( 2013 , 0 , 16 , 19 , 0 , 0 ) ) ;
846
+
847
+ $rootScope . $apply ( function ( ) {
848
+ $rootScope . value = new Date ( Date . UTC ( 2014 , 0 , 16 , 19 , 0 , 0 ) ) ;
849
+ } ) ;
850
+ expect ( inputElm . val ( ) ) . toBe ( '2014-W03' ) ;
851
+ } ) ;
852
+
853
+
817
854
it ( 'should label parse errors as `week`' , function ( ) {
818
855
var inputElm = helper . compileInput ( '<input type="week" ng-model="val" name="alias" />' , {
819
856
valid : false ,
@@ -990,6 +1027,30 @@ describe('input', function() {
990
1027
} ) ;
991
1028
992
1029
1030
+ it ( 'should use any timezone if specified in the options' , function ( ) {
1031
+ var inputElm = helper . compileInput ( '<input type="datetime-local" ng-model="value" ng-model-options="{timezone: \'+0500\'}" />' ) ;
1032
+
1033
+ helper . changeInputValueTo ( '2000-01-01T06:02' ) ;
1034
+ expect ( + $rootScope . value ) . toBe ( Date . UTC ( 2000 , 0 , 1 , 1 , 2 , 0 ) ) ;
1035
+
1036
+ $rootScope . $apply ( function ( ) {
1037
+ $rootScope . value = new Date ( Date . UTC ( 2001 , 0 , 1 , 1 , 2 , 0 ) ) ;
1038
+ } ) ;
1039
+ expect ( inputElm . val ( ) ) . toBe ( '2001-01-01T06:02:00.000' ) ;
1040
+ } ) ;
1041
+
1042
+
1043
+ it ( 'should fallback to default timezone in case an unknown timezone was passed' , function ( ) {
1044
+ var inputElm = helper . compileInput (
1045
+ '<input type="datetime-local" ng-model="value1" ng-model-options="{timezone: \'WTF\'}" />' +
1046
+ '<input type="datetime-local" ng-model="value2" />' ) ;
1047
+
1048
+ helper . changeGivenInputTo ( inputElm . eq ( 0 ) , '2000-01-01T06:02' ) ;
1049
+ helper . changeGivenInputTo ( inputElm . eq ( 1 ) , '2000-01-01T06:02' ) ;
1050
+ expect ( $rootScope . value1 ) . toEqual ( $rootScope . value2 ) ;
1051
+ } ) ;
1052
+
1053
+
993
1054
it ( 'should allow to specify the milliseconds' , function ( ) {
994
1055
var inputElm = helper . compileInput ( '<input type="datetime-local" ng-model="value"" />' ) ;
995
1056
@@ -1278,6 +1339,19 @@ describe('input', function() {
1278
1339
} ) ;
1279
1340
1280
1341
1342
+ it ( 'should use any timezone if specified in the options' , function ( ) {
1343
+ var inputElm = helper . compileInput ( '<input type="time" ng-model="value" ng-model-options="{timezone: \'+0500\'}" />' ) ;
1344
+
1345
+ helper . changeInputValueTo ( '23:02:00' ) ;
1346
+ expect ( + $rootScope . value ) . toBe ( Date . UTC ( 1970 , 0 , 1 , 18 , 2 , 0 ) ) ;
1347
+
1348
+ $rootScope . $apply ( function ( ) {
1349
+ $rootScope . value = new Date ( Date . UTC ( 1971 , 0 , 1 , 18 , 2 , 0 ) ) ;
1350
+ } ) ;
1351
+ expect ( inputElm . val ( ) ) . toBe ( '23:02:00.000' ) ;
1352
+ } ) ;
1353
+
1354
+
1281
1355
it ( 'should allow to specify the milliseconds' , function ( ) {
1282
1356
var inputElm = helper . compileInput ( '<input type="time" ng-model="value"" />' ) ;
1283
1357
@@ -1559,6 +1633,19 @@ describe('input', function() {
1559
1633
} ) ;
1560
1634
1561
1635
1636
+ it ( 'should use any timezone if specified in the options' , function ( ) {
1637
+ var inputElm = helper . compileInput ( '<input type="date" ng-model="value" ng-model-options="{timezone: \'+0500\'}" />' ) ;
1638
+
1639
+ helper . changeInputValueTo ( '2000-01-01' ) ;
1640
+ expect ( + $rootScope . value ) . toBe ( Date . UTC ( 1999 , 11 , 31 , 19 , 0 , 0 ) ) ;
1641
+
1642
+ $rootScope . $apply ( function ( ) {
1643
+ $rootScope . value = new Date ( Date . UTC ( 2000 , 11 , 31 , 19 , 0 , 0 ) ) ;
1644
+ } ) ;
1645
+ expect ( inputElm . val ( ) ) . toBe ( '2001-01-01' ) ;
1646
+ } ) ;
1647
+
1648
+
1562
1649
it ( 'should label parse errors as `date`' , function ( ) {
1563
1650
var inputElm = helper . compileInput ( '<input type="date" ng-model="val" name="alias" />' , {
1564
1651
valid : false ,
0 commit comments