@@ -12,10 +12,10 @@ var URL_REGEXP = /^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\
12
12
var EMAIL_REGEXP = / ^ [ a - z 0 - 9 ! # $ % & ' * + \/ = ? ^ _ ` { | } ~ . - ] + @ [ a - z 0 - 9 ] ( [ a - z 0 - 9 - ] * [ a - z 0 - 9 ] ) ? ( \. [ a - z 0 - 9 ] ( [ a - z 0 - 9 - ] * [ a - z 0 - 9 ] ) ? ) * $ / i;
13
13
var NUMBER_REGEXP = / ^ \s * ( \- | \+ ) ? ( \d + | ( \d * ( \. \d * ) ) ) \s * $ / ;
14
14
var DATE_REGEXP = / ^ ( \d { 4 } ) - ( \d { 2 } ) - ( \d { 2 } ) $ / ;
15
- var DATETIMELOCAL_REGEXP = / ^ ( \d { 4 } ) - ( \d \d ) - ( \d \d ) T ( \d \d ) : ( \d \d ) $ / ;
15
+ var DATETIMELOCAL_REGEXP = / ^ ( \d { 4 } ) - ( \d \d ) - ( \d \d ) T ( \d \d ) : ( \d \d ) (?: : ( \d \d ) ) ? $ / ;
16
16
var WEEK_REGEXP = / ^ ( \d { 4 } ) - W ( \d \d ) $ / ;
17
17
var MONTH_REGEXP = / ^ ( \d { 4 } ) - ( \d \d ) $ / ;
18
- var TIME_REGEXP = / ^ ( \d \d ) : ( \d \d ) $ / ;
18
+ var TIME_REGEXP = / ^ ( \d \d ) : ( \d \d ) (?: : ( \d \d ) ) ? $ / ;
19
19
var DEFAULT_REGEXP = / ( \s + | ^ ) d e f a u l t ( \s + | $ ) / ;
20
20
21
21
var inputType = {
@@ -199,17 +199,17 @@ var inputType = {
199
199
* @description
200
200
* Input with datetime validation and transformation. In browsers that do not yet support
201
201
* the HTML5 date input, a text element will be used. In that case, the text must be entered in a valid ISO-8601
202
- * local datetime format (yyyy-MM-ddTHH:mm), for example: `2010-12-28T14:57`. The model must be a Date object.
202
+ * local datetime format (yyyy-MM-ddTHH:mm:ss ), for example: `2010-12-28T14:57:00 `. The model must be a Date object.
203
203
*
204
204
* The timezone to be used to read/write the `Date` instance in the model can be defined using
205
205
* {@link ng.directive:ngModelOptions ngModelOptions}. By default, this is the timezone of the browser.
206
206
*
207
207
* @param {string } ngModel Assignable angular expression to data-bind to.
208
208
* @param {string= } name Property name of the form under which the control is published.
209
209
* @param {string= } min Sets the `min` validation error key if the value entered is less than `min`. This must be a
210
- * valid ISO datetime format (yyyy-MM-ddTHH:mm).
210
+ * valid ISO datetime format (yyyy-MM-ddTHH:mm:ss ).
211
211
* @param {string= } max Sets the `max` validation error key if the value entered is greater than `max`. This must be
212
- * a valid ISO datetime format (yyyy-MM-ddTHH:mm).
212
+ * a valid ISO datetime format (yyyy-MM-ddTHH:mm:ss ).
213
213
* @param {string= } required Sets `required` validation error key if the value is not entered.
214
214
* @param {string= } ngRequired Adds `required` attribute and `required` validation constraint to
215
215
* the element when the ngRequired expression evaluates to true. Use `ngRequired` instead of
@@ -229,20 +229,20 @@ var inputType = {
229
229
<form name="myForm" ng-controller="DateController as dateCtrl">
230
230
Pick a date between in 2013:
231
231
<input type="datetime-local" id="exampleInput" name="input" ng-model="value"
232
- placeholder="yyyy-MM-ddTHH:mm" min="2001-01-01T00:00" max="2013-12-31T00:00" required />
232
+ placeholder="yyyy-MM-ddTHH:mm:ss " min="2001-01-01T00:00:00 " max="2013-12-31T00:00 :00" required />
233
233
<span class="error" ng-show="myForm.input.$error.required">
234
234
Required!</span>
235
235
<span class="error" ng-show="myForm.input.$error.datetimelocal">
236
236
Not a valid date!</span>
237
- <tt>value = {{value | date: "yyyy-MM-ddTHH:mm"}}</tt><br/>
237
+ <tt>value = {{value | date: "yyyy-MM-ddTHH:mm:ss "}}</tt><br/>
238
238
<tt>myForm.input.$valid = {{myForm.input.$valid}}</tt><br/>
239
239
<tt>myForm.input.$error = {{myForm.input.$error}}</tt><br/>
240
240
<tt>myForm.$valid = {{myForm.$valid}}</tt><br/>
241
241
<tt>myForm.$error.required = {{!!myForm.$error.required}}</tt><br/>
242
242
</form>
243
243
</file>
244
244
<file name="protractor.js" type="protractor">
245
- var value = element(by.binding('value | date: "yyyy-MM-ddTHH:mm"'));
245
+ var value = element(by.binding('value | date: "yyyy-MM-ddTHH:mm:ss "'));
246
246
var valid = element(by.binding('myForm.input.$valid'));
247
247
var input = element(by.model('value'));
248
248
@@ -258,7 +258,7 @@ var inputType = {
258
258
}
259
259
260
260
it('should initialize to model', function() {
261
- expect(value.getText()).toContain('2010-12-28T14:57');
261
+ expect(value.getText()).toContain('2010-12-28T14:57:00 ');
262
262
expect(valid.getText()).toContain('myForm.input.$valid = true');
263
263
});
264
264
@@ -269,16 +269,16 @@ var inputType = {
269
269
});
270
270
271
271
it('should be invalid if over max', function() {
272
- setInput('2015-01-01T23:59');
272
+ setInput('2015-01-01T23:59:00 ');
273
273
expect(value.getText()).toContain('');
274
274
expect(valid.getText()).toContain('myForm.input.$valid = false');
275
275
});
276
276
</file>
277
277
</example>
278
278
*/
279
279
'datetime-local' : createDateInputType ( 'datetimelocal' , DATETIMELOCAL_REGEXP ,
280
- createDateParser ( DATETIMELOCAL_REGEXP , [ 'yyyy' , 'MM' , 'dd' , 'HH' , 'mm' ] ) ,
281
- 'yyyy-MM-ddTHH:mm' ) ,
280
+ createDateParser ( DATETIMELOCAL_REGEXP , [ 'yyyy' , 'MM' , 'dd' , 'HH' , 'mm' , 'ss' ] ) ,
281
+ 'yyyy-MM-ddTHH:mm:ss ' ) ,
282
282
283
283
/**
284
284
* @ngdoc input
@@ -287,18 +287,18 @@ var inputType = {
287
287
* @description
288
288
* Input with time validation and transformation. In browsers that do not yet support
289
289
* the HTML5 date input, a text element will be used. In that case, the text must be entered in a valid ISO-8601
290
- * local time format (HH:mm), for example: `14:57`. Model must be a Date object. This binding will always output a
291
- * Date object to the model of January 1, 1970, or local date `new Date(1970, 0, 1, HH, mm)`.
290
+ * local time format (HH:mm:ss ), for example: `14:57:00 `. Model must be a Date object. This binding will always output a
291
+ * Date object to the model of January 1, 1970, or local date `new Date(1970, 0, 1, HH, mm, ss )`.
292
292
*
293
293
* The timezone to be used to read/write the `Date` instance in the model can be defined using
294
294
* {@link ng.directive:ngModelOptions ngModelOptions}. By default, this is the timezone of the browser.
295
295
*
296
296
* @param {string } ngModel Assignable angular expression to data-bind to.
297
297
* @param {string= } name Property name of the form under which the control is published.
298
298
* @param {string= } min Sets the `min` validation error key if the value entered is less than `min`. This must be a
299
- * valid ISO time format (HH:mm).
299
+ * valid ISO time format (HH:mm:ss ).
300
300
* @param {string= } max Sets the `max` validation error key if the value entered is greater than `max`. This must be a
301
- * valid ISO time format (HH:mm).
301
+ * valid ISO time format (HH:mm:ss ).
302
302
* @param {string= } required Sets `required` validation error key if the value is not entered.
303
303
* @param {string= } ngRequired Adds `required` attribute and `required` validation constraint to
304
304
* the element when the ngRequired expression evaluates to true. Use `ngRequired` instead of
@@ -312,26 +312,26 @@ var inputType = {
312
312
<script>
313
313
angular.module('timeExample', [])
314
314
.controller('DateController', ['$scope', function($scope) {
315
- $scope.value = new Date(1970, 0, 1, 14, 57);
315
+ $scope.value = new Date(1970, 0, 1, 14, 57, 0 );
316
316
}]);
317
317
</script>
318
318
<form name="myForm" ng-controller="DateController as dateCtrl">
319
319
Pick a between 8am and 5pm:
320
320
<input type="time" id="exampleInput" name="input" ng-model="value"
321
- placeholder="HH:mm" min="08:00" max="17:00" required />
321
+ placeholder="HH:mm:ss " min="08:00:00 " max="17:00 :00" required />
322
322
<span class="error" ng-show="myForm.input.$error.required">
323
323
Required!</span>
324
324
<span class="error" ng-show="myForm.input.$error.time">
325
325
Not a valid date!</span>
326
- <tt>value = {{value | date: "HH:mm"}}</tt><br/>
326
+ <tt>value = {{value | date: "HH:mm:ss "}}</tt><br/>
327
327
<tt>myForm.input.$valid = {{myForm.input.$valid}}</tt><br/>
328
328
<tt>myForm.input.$error = {{myForm.input.$error}}</tt><br/>
329
329
<tt>myForm.$valid = {{myForm.$valid}}</tt><br/>
330
330
<tt>myForm.$error.required = {{!!myForm.$error.required}}</tt><br/>
331
331
</form>
332
332
</file>
333
333
<file name="protractor.js" type="protractor">
334
- var value = element(by.binding('value | date: "HH:mm"'));
334
+ var value = element(by.binding('value | date: "HH:mm:ss "'));
335
335
var valid = element(by.binding('myForm.input.$valid'));
336
336
var input = element(by.model('value'));
337
337
@@ -347,7 +347,7 @@ var inputType = {
347
347
}
348
348
349
349
it('should initialize to model', function() {
350
- expect(value.getText()).toContain('14:57');
350
+ expect(value.getText()).toContain('14:57:00 ');
351
351
expect(valid.getText()).toContain('myForm.input.$valid = true');
352
352
});
353
353
@@ -358,16 +358,16 @@ var inputType = {
358
358
});
359
359
360
360
it('should be invalid if over max', function() {
361
- setInput('23:59');
361
+ setInput('23:59:00 ');
362
362
expect(value.getText()).toContain('');
363
363
expect(valid.getText()).toContain('myForm.input.$valid = false');
364
364
});
365
365
</file>
366
366
</example>
367
367
*/
368
368
'time' : createDateInputType ( 'time' , TIME_REGEXP ,
369
- createDateParser ( TIME_REGEXP , [ 'HH' , 'mm' ] ) ,
370
- 'HH:mm' ) ,
369
+ createDateParser ( TIME_REGEXP , [ 'HH' , 'mm' , 'ss' ] ) ,
370
+ 'HH:mm:ss ' ) ,
371
371
372
372
/**
373
373
* @ngdoc input
@@ -1057,15 +1057,14 @@ function createDateParser(regexp, mapping) {
1057
1057
1058
1058
if ( parts ) {
1059
1059
parts . shift ( ) ;
1060
- map = { yyyy : 1970 , MM : 1 , dd : 1 , HH : 0 , mm : 0 } ;
1060
+ map = { yyyy : 1970 , MM : 1 , dd : 1 , HH : 0 , mm : 0 , ss : 0 } ;
1061
1061
1062
1062
forEach ( parts , function ( part , index ) {
1063
1063
if ( index < mapping . length ) {
1064
1064
map [ mapping [ index ] ] = + part ;
1065
1065
}
1066
1066
} ) ;
1067
-
1068
- return new Date ( map . yyyy , map . MM - 1 , map . dd , map . HH , map . mm ) ;
1067
+ return new Date ( map . yyyy , map . MM - 1 , map . dd , map . HH , map . mm , map . ss || 0 ) ;
1069
1068
}
1070
1069
}
1071
1070
0 commit comments