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

Commit

Permalink
feat(dateparser): add support for the h format
Browse files Browse the repository at this point in the history
- Adds support for the `h` format

Closes #4220
  • Loading branch information
JonathanGawrych authored and wesleycho committed Aug 17, 2015
1 parent 734bd6a commit 550fe20
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/dateparser/dateparser.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ angular.module('ui.bootstrap.dateparser', [])
regex: '1?[0-9]|2[0-3]',
apply: function(value) { this.hours = +value; }
},
'h': {
regex: '[0-9]|1[0-2]',
apply: function(value) { this.hours = +value; }
},
'mm': {
regex: '[0-5][0-9]',
apply: function(value) { this.minutes = +value; }
Expand Down
8 changes: 8 additions & 0 deletions src/dateparser/test/dateparser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ describe('date parser', function() {
expectParse('11-08-13 23', 'd-MM-yy H', new Date(2013, 7, 11, 23));
});

it('should work correctly for `h`', function() {
expectParse('22.March.15.12', 'd.MMMM.yy.h', new Date(2015, 2, 22, 12));
expectParse('8-March-1991-11', 'd-MMMM-yyyy-h', new Date(1991, 2, 8, 11));
expectParse('February/5/1980/0', 'MMMM/d/yyyy/h', new Date(1980, 1, 5, 0));
expectParse('1955/February/5 3', 'yyyy/MMMM/d h', new Date(1955, 1, 5, 3));
expectParse('11-08-13 3', 'd-MM-yy h', new Date(2013, 7, 11, 3));
});

it('should work correctly for `mm`', function() {
expectParse('22.March.15.22', 'd.MMMM.yy.mm', new Date(2015, 2, 22, 0, 22));
expectParse('8-March-1991-59', 'd-MMMM-yyyy-mm', new Date(1991, 2, 8, 0, 59));
Expand Down

0 comments on commit 550fe20

Please sign in to comment.