Support 's' and '\' in date() #56

Merged
merged 2 commits into from Jan 4, 2017

Projects

None yet

2 participants

@jacobembree

No description provided.

+ if (seconds.length == 1) { seconds = '0' + seconds; }
+ result += seconds;
+ break;
+
@signalpoint
signalpoint Dec 29, 2016 Owner

@jacobembree This looks great, thanks.

@jacobembree
jacobembree Jan 4, 2017

Splendid. Since I'm a new user of pull requests on Github, I don't know if your positive review is meant to apply only to the lines I see, 264-267, or to the whole patch. Is there anything I need to do? Do you want me to submit another patch without the backslash support?

src/core.js
+ grab_next = true;
+ console.log(grab_next);
+ continue;
+
@signalpoint
signalpoint Jan 4, 2017 Owner

@jacobembree I'm confused by what grab_next and the \\ are used for. Would you please provide an example input/output of what this produces? Thanks.

@signalpoint
signalpoint Jan 4, 2017 Owner

@jacobembree This is the only snippet I am concerned/confused about. Please let me know when you have a chance, thanks.

@jacobembree
jacobembree Jan 4, 2017

Well, console.log(grab_next) isn't supposed to be there actually.
When someone calls something like date('Day: d') the "D" and "a" are interpreted as tokens. The backslash is supported in PHP as an escape token so that you can call date('\D\ay: d). The backslashes themselves need to be escaped though to work, so the call becomes date('\\D\\ay: d).
The way this patch works is when it detects a backslash it grabs the next character literally rather than checking it for a token.

@signalpoint signalpoint merged commit 54a63dc into signalpoint:7.x-1.x Jan 4, 2017
@jacobembree jacobembree deleted the jacobembree:7.x-1.x-date-seconds branch Jan 4, 2017
@jacobembree jacobembree restored the jacobembree:7.x-1.x-date-seconds branch Jan 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment