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

Commit 25ff206

Browse files
Jannewesleycho
Janne
authored andcommitted
feat(dateparser): add LLLL support
- Add LLLL support. This requires Angular 1.5+ to take advantage of this. Closes #6281
1 parent 997813f commit 25ff206

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

src/dateparser/dateparser.js

+6
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ angular.module('ui.bootstrap.dateparser', [])
8181
apply: function(value) { this.month = value - 1; },
8282
formatter: function(date) { return dateFilter(date, 'M'); }
8383
},
84+
{
85+
key: 'LLLL',
86+
regex: $locale.DATETIME_FORMATS.STANDALONEMONTH.join('|'),
87+
apply: function(value) { this.month = $locale.DATETIME_FORMATS.STANDALONEMONTH.indexOf(value); },
88+
formatter: function(date) { return dateFilter(date, 'LLLL'); }
89+
},
8490
{
8591
key: 'd!',
8692
regex: '[0-2]?[0-9]{1}|3[0-1]{1}',

src/dateparser/docs/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ Certain format codes support i18n. Check this [guide](https://docs.angularjs.org
5858
_(Example: `3` or `03`)_ -
5959
Parses a numeric month, but allowing an optional leading zero
6060

61+
* `LLLL`
62+
_(Example: `February`, i18n support)_ - Stand-alone month in year (January-December). Requires Angular version 1.5.1 or higher.
63+
6164
* `dd`
6265
_(Example: `05`, Leading 0)_ -
6366
Parses a numeric day.

src/dateparser/test/dateparser.spec.js

+10
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,16 @@ describe('date parser', function() {
8484
expectFilter(new Date(2011, 4, 2, 0), 'dd-M!-yy', '02-05-11');
8585
expectFilter(oldDate, 'yyyy/M!/dd', '0001/03/06');
8686
});
87+
88+
it('should work correctly for `LLLL`', function() {
89+
expectFilter(new Date(2013, 7, 24, 0), 'LLLL/dd/yyyy', 'August/24/2013');
90+
expectFilter(new Date(2004, 10, 7, 0), 'dd.LLLL.yy', '07.November.04');
91+
expectFilter(new Date(2011, 4, 18, 0), 'dd-LLLL-yy', '18-May-11');
92+
expectFilter(new Date(1980, 1, 5, 0), 'LLLL/dd/yyyy', 'February/05/1980');
93+
expectFilter(new Date(1955, 2, 5, 0), 'yyyy/LLLL/dd', '1955/March/05');
94+
expectFilter(new Date(2011, 5, 2, 0), 'dd-LLLL-yy', '02-June-11');
95+
expectFilter(oldDate, 'yyyy/LLLL/dd', '0001/March/06');
96+
});
8797

8898
it('should work correctly for `d`', function() {
8999
expectFilter(new Date(2013, 10, 17, 0), 'd.MMMM.yy', '17.November.13');

0 commit comments

Comments
 (0)