-
Notifications
You must be signed in to change notification settings - Fork 7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
moment.fn.format escape multiple characters is partially broken by Localized date format #380
Comments
The problem is with how moment expands while (localFormattingTokens.test(format)) {
format = format.replace(localFormattingTokens, replaceLongDateFormatTokens);
} @timrwood, I'm not sure about how to fix this. |
So the way this works in
However, this also opens the possibility of an infinite loop if moment.longDateFormat.LT = "h:mm A";
moment.longDateFormat.L = "MM/DD/YYYY";
moment.longDateFormat.LL = "MMMM D YYYY";
moment.longDateFormat.LLL = "LL LT";
moment.longDateFormat.LLLL = "dddd, LLL"; If we think the above should be supported we'll have to think of another way to limit the var lang = getLangDefinition(m), i = 5;
...
while (i-- && localFormattingTokens.test(format)) {
format = format.replace(localFormattingTokens, replaceLongDateFormatTokens);
} |
Why would the localDate formats not be implemented the same as other formats? P.S. I'm on my phone and don't have the code in front of me, so this question may sound uninformed. On Aug 3, 2012, at 11:28 AM, Tim Woodreply@reply.github.com wrote:
|
The localDate formats are actually more like macros than formats. They don't correspond to values, they correspond to other formats. |
Ah ok, makes sense. In that case, would it be possible to apply the same escaping logic as the others? |
Yeah, the commit I added fixes this, but it doesn't handle more than 2 levels of recursion as shown in my comment above. |
Oops, forgot to tag this commit. 12aad5f I added up to 5 levels of recursion and an early escape if it doesn't match |
This has been released with |
It appears that the substitution for localized date format doesn't respect the multiple character escape.
moment().format('[Last] dddd') #> "MM/DD/YYYYast Monday"
moment().format('[LLL] LLL') #> "MMMM D YYYY h:mm A July 30 2012 8:47 AM"
The text was updated successfully, but these errors were encountered: