This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(filter.date): add support for default datetime formats in en
- add support for full,long, medium, short datetime formats in en Breaks MMMMM. now we don't support MMMMM anymore as old implementation differs from Unicode Locale Data format we are following. - removed support for fullDateTime and fullTime as it means too much trouble with full timeZone names - added docs for the new features
- Loading branch information
Showing
4 changed files
with
133 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,8 +111,10 @@ describe('filter', function() { | |
}); | ||
|
||
it('should handle mailto:', function() { | ||
expect(linky("mailto:[email protected]").html).toEqual('<a href="mailto:[email protected]">[email protected]</a>'); | ||
expect(linky("[email protected]").html).toEqual('<a href="mailto:[email protected]">[email protected]</a>'); | ||
expect(linky("mailto:[email protected]").html). | ||
toEqual('<a href="mailto:[email protected]">[email protected]</a>'); | ||
expect(linky("[email protected]").html). | ||
toEqual('<a href="mailto:[email protected]">[email protected]</a>'); | ||
expect(linky("send email to [email protected], but").html). | ||
toEqual('send email to <a href="mailto:[email protected]">[email protected]</a>, but'); | ||
}); | ||
|
@@ -123,6 +125,9 @@ describe('filter', function() { | |
var morning = new TzDate(+5, '2010-09-03T12:05:08.000Z'); //7am | ||
var noon = new TzDate(+5, '2010-09-03T17:05:08.000Z'); //12pm | ||
var midnight = new TzDate(+5, '2010-09-03T05:05:08.000Z'); //12am | ||
var earlyDate = new TzDate(+5, '0001-09-03T05:05:08.000Z'); | ||
var timZoneDate = new TzDate(+5, '2010-09-03T05:05:08.000Z', | ||
'Mon Sep 3 2010 00:05:08 GMT+0500 (XYZ)'); //12am | ||
|
||
it('should ignore falsy inputs', function() { | ||
expect(filter.date(null)).toBeNull(); | ||
|
@@ -141,24 +146,79 @@ describe('filter', function() { | |
|
||
it('should accept various format strings', function() { | ||
expect(filter.date(morning, "yy-MM-dd HH:mm:ss")). | ||
toEqual('10-09-03 07:05:08'); | ||
toEqual('10-09-03 07:05:08'); | ||
|
||
expect(filter.date(midnight, "yyyy-M-d h=H:m:saZ")). | ||
toEqual('2010-9-3 12=0:5:8am0500'); | ||
toEqual('2010-9-3 12=0:5:8am0500'); | ||
|
||
expect(filter.date(midnight, "yyyy-MM-dd hh=HH:mm:ssaZ")). | ||
toEqual('2010-09-03 12=00:05:08am0500'); | ||
toEqual('2010-09-03 12=00:05:08am0500'); | ||
|
||
expect(filter.date(noon, "yyyy-MM-dd hh=HH:mm:ssaZ")). | ||
toEqual('2010-09-03 12=12:05:08pm0500'); | ||
toEqual('2010-09-03 12=12:05:08pm0500'); | ||
|
||
expect(filter.date(timZoneDate, "yyyy-MM-dd hh=HH:mm:ss a z")). | ||
toEqual('2010-09-03 12=00:05:08 am XYZ'); | ||
|
||
expect(filter.date(noon, "EEE, MMM d, yyyy")). | ||
toEqual('Fri, Sep 3, 2010'); | ||
toEqual('Fri, Sep 3, 2010'); | ||
|
||
expect(filter.date(noon, "EEEE, MMMM dd, yyyy")). | ||
toEqual('Friday, September 03, 2010'); | ||
|
||
expect(filter.date(earlyDate, "MMMM dd, y")). | ||
toEqual('September 03, 1'); | ||
}); | ||
|
||
it('should accept default formats', function() { | ||
|
||
expect(filter.date(timZoneDate, "long")). | ||
toEqual('September 3, 2010 12:05:08 am XYZ'); | ||
|
||
expect(filter.date(noon, "medium")). | ||
toEqual('Sep 3, 2010 12:05:08 pm'); | ||
|
||
expect(filter.date(noon, "short")). | ||
toEqual('9/3/10 12:05 pm'); | ||
|
||
expect(filter.date(noon, "fullDate")). | ||
toEqual('Friday, September 3, 2010'); | ||
|
||
expect(filter.date(noon, "longDate")). | ||
toEqual('September 3, 2010'); | ||
|
||
expect(filter.date(noon, "EEEE, MMMMM dd, yyyy")). | ||
toEqual('Friday, September 03, 2010'); | ||
expect(filter.date(noon, "mediumDate")). | ||
toEqual('Sep 3, 2010'); | ||
|
||
expect(filter.date(noon, "shortDate")). | ||
toEqual('9/3/10'); | ||
|
||
expect(filter.date(timZoneDate, "longTime")). | ||
toEqual('12:05:08 am XYZ'); | ||
|
||
expect(filter.date(noon, "mediumTime")). | ||
toEqual('12:05:08 pm'); | ||
|
||
expect(filter.date(noon, "shortTime")). | ||
toEqual('12:05 pm'); | ||
}); | ||
|
||
|
||
it('should parse timezone identifier from various toString values', function() { | ||
//chrome and firefox format | ||
expect(filter.date(new TzDate(+5, '2010-09-03T17:05:08.000Z', | ||
'Mon Sep 3 2010 17:05:08 GMT+0500 (XYZ)'), "z")).toBe('XYZ'); | ||
|
||
//opera format | ||
expect(filter.date(new TzDate(+5, '2010-09-03T17:05:08.000Z', | ||
'2010-09-03T17:05:08Z'), "z")).toBe('0500'); | ||
|
||
//ie 8 format | ||
expect(filter.date(new TzDate(+5, '2010-09-03T17:05:08.000Z', | ||
'Mon Sep 3 17:05:08 XYZ 2010'), "z")).toBe('XYZ'); | ||
}); | ||
|
||
|
||
it('should be able to parse ISO 8601 dates/times using', function() { | ||
var isoString = '2010-09-03T05:05:08.872Z'; | ||
expect(filter.date(isoString)). | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters