-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Date filter can't format date/time with newlines #15794
Comments
I see this more as a feature to be honest. And the workaround you posted is not that bad. But since the change is simple ... let's see what others say. |
I'd argue it's a bug as you can't even embed newlines using escapes. Documentation doesn't mention this limitation:
I don't see why (Incidentally, while trying alternative escape sequences like |
I'd say it's a feature and not a bug, as docs clearly state:
followed by a list which does not include what you're talking about (no it doesn't mention a limitation, but it explicitly lists what you can use). Leaving this aside, I wouldn't say it hurts adding this even though I'd think the use-cases for this are limited. |
A little further investigation: newlines are handled in the first 'token' of the format string. These work: Is that a feature, or is it a bug? The docs are probably missing a description of how 'other characters' are handled (including characters actually used in the US-default date format strings: e.g. colons, commas, slashes, spaces etc.) Perhaps the docs need to include this, as used in other libraries - for example: PHP:
Or Java:
|
I would say this is obviously a bug in the Also, 👍 on updating the docs to mention that unrecognized characters are printed as-is (or something similar). |
Ok, then let's go with the PR |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Using a date format containing a newline is treated as though the format ended at the newline.
i.e.
| date: 'dd MMM\nyyyy'
is treated as though it were| date: 'dd MMM'
Plunkers: Angular 1.5.10, Angular 1.6.3, Angular 2.unknown
What is the expected behavior?
The format string should be processed in its entirety.
What is the motivation / use case for changing the behavior?
A UI design required a timestamp to be formatted with date and time separated by a newline. This should be as simple as
| date: 'yyyy-MM-dd\nHH:mm'
(assuming an appropriate CSSwhite-space
value.)Which versions of AngularJS, and which browser / OS are affected by this issue? Did this work in previous versions of AngularJS? Please also test with the latest stable and snapshot (https://code.angularjs.org/snapshot/) versions.
Appears to affect all versions of since at least March 2012, including angular 2
Other information (e.g. stacktraces, related issues, suggestions how to fix)
Fix in pull request #15792
The text was updated successfully, but these errors were encountered: