Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 7e239f9

Browse files
dennishall1caitp
authored andcommitted
docs(dateFilter): add example of string literals in format string
Also changes the wording to include the word "escaped" and "escape", which may help users find the information they're looking for via searching. (ノ◕ヮ◕)ノ*:・゚✧ Closes #8770
1 parent fa5daa7 commit 7e239f9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/ng/filter/filters.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,8 @@ var DATE_FORMATS_SPLIT = /((?:[^yMdHhmsaZE']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|d+
322322
* * `'mediumTime'`: equivalent to `'h:mm:ss a'` for en_US locale (e.g. 12:05:08 pm)
323323
* * `'shortTime'`: equivalent to `'h:mm a'` for en_US locale (e.g. 12:05 pm)
324324
*
325-
* `format` string can contain literal values. These need to be quoted with single quotes (e.g.
326-
* `"h 'in the morning'"`). In order to output single quote, use two single quotes in a sequence
325+
* `format` string can contain literal values. These need to be escaped by surrounding with single quotes (e.g.
326+
* `"h 'in the morning'"`). In order to output a single quote, escape it - i.e., two single quotes in a sequence
327327
* (e.g. `"h 'o''clock'"`).
328328
*
329329
* @param {(Date|number|string)} date Date to format either as Date object, milliseconds (string or
@@ -343,6 +343,8 @@ var DATE_FORMATS_SPLIT = /((?:[^yMdHhmsaZE']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|d+
343343
<span>{{1288323623006 | date:'yyyy-MM-dd HH:mm:ss Z'}}</span><br>
344344
<span ng-non-bindable>{{1288323623006 | date:'MM/dd/yyyy @ h:mma'}}</span>:
345345
<span>{{'1288323623006' | date:'MM/dd/yyyy @ h:mma'}}</span><br>
346+
<span ng-non-bindable>{{1288323623006 | date:"MM/dd/yyyy 'at' h:mma"}}</span>:
347+
<span>{{'1288323623006' | date:"MM/dd/yyyy 'at' h:mma"}}</span><br>
346348
</file>
347349
<file name="protractor.js" type="protractor">
348350
it('should format date', function() {
@@ -352,6 +354,8 @@ var DATE_FORMATS_SPLIT = /((?:[^yMdHhmsaZE']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|d+
352354
toMatch(/2010\-10\-2\d \d{2}:\d{2}:\d{2} (\-|\+)?\d{4}/);
353355
expect(element(by.binding("'1288323623006' | date:'MM/dd/yyyy @ h:mma'")).getText()).
354356
toMatch(/10\/2\d\/2010 @ \d{1,2}:\d{2}(AM|PM)/);
357+
expect(element(by.binding("'1288323623006' | date:\"MM/dd/yyyy 'at' h:mma\"")).getText()).
358+
toMatch(/10\/2\d\/2010 at \d{1,2}:\d{2}(AM|PM)/);
355359
});
356360
</file>
357361
</example>

0 commit comments

Comments
 (0)