@@ -1627,6 +1627,18 @@ describe('input', function() {
1627
1627
expect ( inputElm ) . toBeValid ( ) ;
1628
1628
} ) ;
1629
1629
1630
+ it ( 'should use UTC if specified in the options' , function ( ) {
1631
+ compileInput ( '<input type="month" ng-model="value" ng-model-options="{timezone: \'UTC\'}" />' ) ;
1632
+
1633
+ changeInputValueTo ( '2013-07' ) ;
1634
+ expect ( + scope . value ) . toBe ( Date . UTC ( 2013 , 6 , 1 ) ) ;
1635
+
1636
+ scope . $apply ( function ( ) {
1637
+ scope . value = new Date ( Date . UTC ( 2014 , 6 , 1 ) ) ;
1638
+ } ) ;
1639
+ expect ( inputElm . val ( ) ) . toBe ( '2014-07' ) ;
1640
+ } ) ;
1641
+
1630
1642
1631
1643
describe ( 'min' , function ( ) {
1632
1644
beforeEach ( function ( ) {
@@ -1746,6 +1758,18 @@ describe('input', function() {
1746
1758
expect ( inputElm ) . toBeValid ( ) ;
1747
1759
} ) ;
1748
1760
1761
+ it ( 'should use UTC if specified in the options' , function ( ) {
1762
+ compileInput ( '<input type="week" ng-model="value" ng-model-options="{timezone: \'UTC\'}" />' ) ;
1763
+
1764
+ changeInputValueTo ( '2013-W03' ) ;
1765
+ expect ( + scope . value ) . toBe ( Date . UTC ( 2013 , 0 , 17 ) ) ;
1766
+
1767
+ scope . $apply ( function ( ) {
1768
+ scope . value = new Date ( Date . UTC ( 2014 , 0 , 17 ) ) ;
1769
+ } ) ;
1770
+ expect ( inputElm . val ( ) ) . toBe ( '2014-W03' ) ;
1771
+ } ) ;
1772
+
1749
1773
describe ( 'min' , function ( ) {
1750
1774
beforeEach ( function ( ) {
1751
1775
compileInput ( '<input type="week" ng-model="value" name="alias" min="2013-W01" />' ) ;
@@ -1863,6 +1887,18 @@ describe('input', function() {
1863
1887
expect ( inputElm ) . toBeValid ( ) ;
1864
1888
} ) ;
1865
1889
1890
+ it ( 'should use UTC if specified in the options' , function ( ) {
1891
+ compileInput ( '<input type="datetime-local" ng-model="value" ng-model-options="{timezone: \'UTC\'}" />' ) ;
1892
+
1893
+ changeInputValueTo ( '2000-01-01T01:02' ) ;
1894
+ expect ( + scope . value ) . toBe ( Date . UTC ( 2000 , 0 , 1 , 1 , 2 ) ) ;
1895
+
1896
+ scope . $apply ( function ( ) {
1897
+ scope . value = new Date ( Date . UTC ( 2001 , 0 , 1 , 1 , 2 ) ) ;
1898
+ } ) ;
1899
+ expect ( inputElm . val ( ) ) . toBe ( '2001-01-01T01:02' ) ;
1900
+ } ) ;
1901
+
1866
1902
describe ( 'min' , function ( ) {
1867
1903
beforeEach ( function ( ) {
1868
1904
compileInput ( '<input type="datetime-local" ng-model="value" name="alias" min="2000-01-01T12:30" />' ) ;
@@ -1947,7 +1983,7 @@ describe('input', function() {
1947
1983
compileInput ( '<input type="time" ng-model="threeFortyOnePm"/>' ) ;
1948
1984
1949
1985
scope . $apply ( function ( ) {
1950
- scope . threeFortyOnePm = new Date ( 0 , 0 , 1 , 15 , 41 ) ;
1986
+ scope . threeFortyOnePm = new Date ( 1970 , 0 , 1 , 15 , 41 ) ;
1951
1987
} ) ;
1952
1988
1953
1989
expect ( inputElm . val ( ) ) . toBe ( '15:41' ) ;
@@ -1957,7 +1993,7 @@ describe('input', function() {
1957
1993
compileInput ( '<input type="time" ng-model="breakMe"/>' ) ;
1958
1994
1959
1995
scope . $apply ( function ( ) {
1960
- scope . breakMe = new Date ( 0 , 0 , 1 , 16 , 25 ) ;
1996
+ scope . breakMe = new Date ( 1970 , 0 , 1 , 16 , 25 ) ;
1961
1997
} ) ;
1962
1998
1963
1999
expect ( inputElm . val ( ) ) . toBe ( '16:25' ) ;
@@ -2008,6 +2044,18 @@ describe('input', function() {
2008
2044
expect ( inputElm ) . toBeValid ( ) ;
2009
2045
} ) ;
2010
2046
2047
+ it ( 'should use UTC if specified in the options' , function ( ) {
2048
+ compileInput ( '<input type="time" ng-model="value" ng-model-options="{timezone: \'UTC\'}" />' ) ;
2049
+
2050
+ changeInputValueTo ( '23:02' ) ;
2051
+ expect ( + scope . value ) . toBe ( Date . UTC ( 1970 , 0 , 1 , 23 , 2 ) ) ;
2052
+
2053
+ scope . $apply ( function ( ) {
2054
+ scope . value = new Date ( Date . UTC ( 1971 , 0 , 1 , 23 , 2 ) ) ;
2055
+ } ) ;
2056
+ expect ( inputElm . val ( ) ) . toBe ( '23:02' ) ;
2057
+ } ) ;
2058
+
2011
2059
describe ( 'min' , function ( ) {
2012
2060
beforeEach ( function ( ) {
2013
2061
compileInput ( '<input type="time" ng-model="value" name="alias" min="09:30" />' ) ;
@@ -2023,7 +2071,7 @@ describe('input', function() {
2023
2071
it ( 'should validate' , function ( ) {
2024
2072
changeInputValueTo ( '23:02' ) ;
2025
2073
expect ( inputElm ) . toBeValid ( ) ;
2026
- expect ( + scope . value ) . toBe ( + new Date ( 0 , 0 , 1 , 23 , 2 ) ) ;
2074
+ expect ( + scope . value ) . toBe ( + new Date ( 1970 , 0 , 1 , 23 , 2 ) ) ;
2027
2075
expect ( scope . form . alias . $error . min ) . toBeFalsy ( ) ;
2028
2076
} ) ;
2029
2077
} ) ;
@@ -2043,7 +2091,7 @@ describe('input', function() {
2043
2091
it ( 'should validate' , function ( ) {
2044
2092
changeInputValueTo ( '05:30' ) ;
2045
2093
expect ( inputElm ) . toBeValid ( ) ;
2046
- expect ( + scope . value ) . toBe ( + new Date ( 0 , 0 , 1 , 5 , 30 ) ) ;
2094
+ expect ( + scope . value ) . toBe ( + new Date ( 1970 , 0 , 1 , 5 , 30 ) ) ;
2047
2095
expect ( scope . form . alias . $error . max ) . toBeFalsy ( ) ;
2048
2096
} ) ;
2049
2097
} ) ;
@@ -2153,6 +2201,18 @@ describe('input', function() {
2153
2201
expect ( inputElm ) . toBeValid ( ) ;
2154
2202
} ) ;
2155
2203
2204
+ it ( 'should use UTC if specified in the options' , function ( ) {
2205
+ compileInput ( '<input type="date" ng-model="value" ng-model-options="{timezone: \'UTC\'}" />' ) ;
2206
+
2207
+ changeInputValueTo ( '2000-01-01' ) ;
2208
+ expect ( + scope . value ) . toBe ( Date . UTC ( 2000 , 0 , 1 ) ) ;
2209
+
2210
+ scope . $apply ( function ( ) {
2211
+ scope . value = new Date ( Date . UTC ( 2001 , 0 , 1 ) ) ;
2212
+ } ) ;
2213
+ expect ( inputElm . val ( ) ) . toBe ( '2001-01-01' ) ;
2214
+ } ) ;
2215
+
2156
2216
describe ( 'min' , function ( ) {
2157
2217
beforeEach ( function ( ) {
2158
2218
compileInput ( '<input type="date" ng-model="value" name="alias" min="2000-01-01" />' ) ;
0 commit comments