Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit 550fe20

Browse files
JonathanGawrychwesleycho
authored andcommitted
feat(dateparser): add support for the h format
- Adds support for the `h` format Closes #4220
1 parent 734bd6a commit 550fe20

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

Diff for: src/dateparser/dateparser.js

+4
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ angular.module('ui.bootstrap.dateparser', [])
6161
regex: '1?[0-9]|2[0-3]',
6262
apply: function(value) { this.hours = +value; }
6363
},
64+
'h': {
65+
regex: '[0-9]|1[0-2]',
66+
apply: function(value) { this.hours = +value; }
67+
},
6468
'mm': {
6569
regex: '[0-5][0-9]',
6670
apply: function(value) { this.minutes = +value; }

Diff for: src/dateparser/test/dateparser.spec.js

+8
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@ describe('date parser', function() {
8686
expectParse('11-08-13 23', 'd-MM-yy H', new Date(2013, 7, 11, 23));
8787
});
8888

89+
it('should work correctly for `h`', function() {
90+
expectParse('22.March.15.12', 'd.MMMM.yy.h', new Date(2015, 2, 22, 12));
91+
expectParse('8-March-1991-11', 'd-MMMM-yyyy-h', new Date(1991, 2, 8, 11));
92+
expectParse('February/5/1980/0', 'MMMM/d/yyyy/h', new Date(1980, 1, 5, 0));
93+
expectParse('1955/February/5 3', 'yyyy/MMMM/d h', new Date(1955, 1, 5, 3));
94+
expectParse('11-08-13 3', 'd-MM-yy h', new Date(2013, 7, 11, 3));
95+
});
96+
8997
it('should work correctly for `mm`', function() {
9098
expectParse('22.March.15.22', 'd.MMMM.yy.mm', new Date(2015, 2, 22, 0, 22));
9199
expectParse('8-March-1991-59', 'd-MMMM-yyyy-mm', new Date(1991, 2, 8, 0, 59));

0 commit comments

Comments
 (0)