-
Notifications
You must be signed in to change notification settings - Fork 440
Add support for escaping characters with the date filter #432
Conversation
If this gets accepted, will it be included in a 1.3.x release, or necessitate a 1.4.0 release? |
{ c: 'v|date("S")', v: makeDate(420, 2011, 8, 23), e: 'rd' }, | ||
|
||
// Escape character | ||
{ c: 'v|date("\\D")', v: d, e: 'D' }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The double-slashes are necessary here to keep the TokenParser happy when performing the tests, and are not necessary in typical use. These tests are modelled after the test styling in the addslashes checks.
@ecaron: I'm not sure. I'll have to review the other changes as well. Probably stay on 1.3.x, I think... |
// Escape character | ||
{ c: 'v|date("\\D")', v: d, e: 'D' }, | ||
{ c: 'v|date("\\t\\e\\s\\t")', v: d, e: 'test' }, | ||
{ c: 'v|date("\\\\D")', v: d, e: '\\Tue' } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I attempted to add a more "real-world" example, and it failed tests...
{ c: 'v|date("jS \o\f F")', v: makeDate(420, 2012, 5, 4), e: '4th of July' }
@ecaron: Do you want to fix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I may have done this wrong... need the extra escapes. Will re-try later tonight...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just going to say that - you're right that they need extra escapes because the first round of slashes gets lost converting the tests to code (just like in the addslashes example.)
Any chance of a publish on this? |
This PR adds character escape support, making the date filter closer to "PHP-style".
PHP usage being modelled is shown at http://us3.php.net/manual/en/function.date.php#example-2306
Per my and @paularmstrong preference, this PR supports one-escape-needed-per-character. As Paul says: