@@ -1627,6 +1627,18 @@ describe('input', function() {
16271627 expect ( inputElm ) . toBeValid ( ) ;
16281628 } ) ;
16291629
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+
16301642
16311643 describe ( 'min' , function ( ) {
16321644 beforeEach ( function ( ) {
@@ -1746,6 +1758,18 @@ describe('input', function() {
17461758 expect ( inputElm ) . toBeValid ( ) ;
17471759 } ) ;
17481760
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+
17491773 describe ( 'min' , function ( ) {
17501774 beforeEach ( function ( ) {
17511775 compileInput ( '<input type="week" ng-model="value" name="alias" min="2013-W01" />' ) ;
@@ -1863,6 +1887,18 @@ describe('input', function() {
18631887 expect ( inputElm ) . toBeValid ( ) ;
18641888 } ) ;
18651889
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+
18661902 describe ( 'min' , function ( ) {
18671903 beforeEach ( function ( ) {
18681904 compileInput ( '<input type="datetime-local" ng-model="value" name="alias" min="2000-01-01T12:30" />' ) ;
@@ -1947,7 +1983,7 @@ describe('input', function() {
19471983 compileInput ( '<input type="time" ng-model="threeFortyOnePm"/>' ) ;
19481984
19491985 scope . $apply ( function ( ) {
1950- scope . threeFortyOnePm = new Date ( 0 , 0 , 1 , 15 , 41 ) ;
1986+ scope . threeFortyOnePm = new Date ( 1970 , 0 , 1 , 15 , 41 ) ;
19511987 } ) ;
19521988
19531989 expect ( inputElm . val ( ) ) . toBe ( '15:41' ) ;
@@ -1957,7 +1993,7 @@ describe('input', function() {
19571993 compileInput ( '<input type="time" ng-model="breakMe"/>' ) ;
19581994
19591995 scope . $apply ( function ( ) {
1960- scope . breakMe = new Date ( 0 , 0 , 1 , 16 , 25 ) ;
1996+ scope . breakMe = new Date ( 1970 , 0 , 1 , 16 , 25 ) ;
19611997 } ) ;
19621998
19631999 expect ( inputElm . val ( ) ) . toBe ( '16:25' ) ;
@@ -2008,6 +2044,18 @@ describe('input', function() {
20082044 expect ( inputElm ) . toBeValid ( ) ;
20092045 } ) ;
20102046
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+
20112059 describe ( 'min' , function ( ) {
20122060 beforeEach ( function ( ) {
20132061 compileInput ( '<input type="time" ng-model="value" name="alias" min="09:30" />' ) ;
@@ -2023,7 +2071,7 @@ describe('input', function() {
20232071 it ( 'should validate' , function ( ) {
20242072 changeInputValueTo ( '23:02' ) ;
20252073 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 ) ) ;
20272075 expect ( scope . form . alias . $error . min ) . toBeFalsy ( ) ;
20282076 } ) ;
20292077 } ) ;
@@ -2043,7 +2091,7 @@ describe('input', function() {
20432091 it ( 'should validate' , function ( ) {
20442092 changeInputValueTo ( '05:30' ) ;
20452093 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 ) ) ;
20472095 expect ( scope . form . alias . $error . max ) . toBeFalsy ( ) ;
20482096 } ) ;
20492097 } ) ;
@@ -2153,6 +2201,18 @@ describe('input', function() {
21532201 expect ( inputElm ) . toBeValid ( ) ;
21542202 } ) ;
21552203
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+
21562216 describe ( 'min' , function ( ) {
21572217 beforeEach ( function ( ) {
21582218 compileInput ( '<input type="date" ng-model="value" name="alias" min="2000-01-01" />' ) ;
0 commit comments