From f64a1b0eddf422fd292132d5fd525b6d032b9a75 Mon Sep 17 00:00:00 2001 From: Janne Date: Mon, 10 Oct 2016 17:33:35 +0300 Subject: [PATCH 1/3] Add standalone month support (LLLL) to dateparser --- src/dateparser/dateparser.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/dateparser/dateparser.js b/src/dateparser/dateparser.js index 732ed4e01b..7a6c866fa5 100644 --- a/src/dateparser/dateparser.js +++ b/src/dateparser/dateparser.js @@ -81,6 +81,12 @@ angular.module('ui.bootstrap.dateparser', []) apply: function(value) { this.month = value - 1; }, formatter: function(date) { return dateFilter(date, 'M'); } }, + { + key: 'LLLL', + regex: $locale.DATETIME_FORMATS.STANDALONEMONTH.join('|'), + apply: function(value) { this.month = $locale.DATETIME_FORMATS.STANDALONEMONTH.indexOf(value); }, + formatter: function(date) { return dateFilter(date, 'LLLL'); } + }, { key: 'd!', regex: '[0-2]?[0-9]{1}|3[0-1]{1}', From 7f032c5026b886f472eded11543cab49da2d7187 Mon Sep 17 00:00:00 2001 From: Janne Date: Mon, 10 Oct 2016 19:32:02 +0300 Subject: [PATCH 2/3] docs(dateparser): add LLLL format code --- src/dateparser/docs/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/dateparser/docs/README.md b/src/dateparser/docs/README.md index d5cc38fab9..f7a3b3434f 100644 --- a/src/dateparser/docs/README.md +++ b/src/dateparser/docs/README.md @@ -58,6 +58,9 @@ Certain format codes support i18n. Check this [guide](https://docs.angularjs.org _(Example: `3` or `03`)_ - Parses a numeric month, but allowing an optional leading zero +* `LLLL` + _(Example: `February`, i18n support)_ - Stand-alone month in year (January-December). Requires Angular version 1.5.1 or higher. + * `dd` _(Example: `05`, Leading 0)_ - Parses a numeric day. From f1ad860993b3a3bc7c4aac9a907ffd2e013da8b7 Mon Sep 17 00:00:00 2001 From: Janne Date: Mon, 10 Oct 2016 19:41:58 +0300 Subject: [PATCH 3/3] test(dateparser): add LLLL support --- src/dateparser/test/dateparser.spec.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/dateparser/test/dateparser.spec.js b/src/dateparser/test/dateparser.spec.js index 419a705bf5..c3f2c5912f 100644 --- a/src/dateparser/test/dateparser.spec.js +++ b/src/dateparser/test/dateparser.spec.js @@ -84,6 +84,16 @@ describe('date parser', function() { expectFilter(new Date(2011, 4, 2, 0), 'dd-M!-yy', '02-05-11'); expectFilter(oldDate, 'yyyy/M!/dd', '0001/03/06'); }); + + it('should work correctly for `LLLL`', function() { + expectFilter(new Date(2013, 7, 24, 0), 'LLLL/dd/yyyy', 'August/24/2013'); + expectFilter(new Date(2004, 10, 7, 0), 'dd.LLLL.yy', '07.November.04'); + expectFilter(new Date(2011, 4, 18, 0), 'dd-LLLL-yy', '18-May-11'); + expectFilter(new Date(1980, 1, 5, 0), 'LLLL/dd/yyyy', 'February/05/1980'); + expectFilter(new Date(1955, 2, 5, 0), 'yyyy/LLLL/dd', '1955/March/05'); + expectFilter(new Date(2011, 5, 2, 0), 'dd-LLLL-yy', '02-June-11'); + expectFilter(oldDate, 'yyyy/LLLL/dd', '0001/March/06'); + }); it('should work correctly for `d`', function() { expectFilter(new Date(2013, 10, 17, 0), 'd.MMMM.yy', '17.November.13');