angular.js icon indicating copy to clipboard operation
angular.js copied to clipboard

Date filter am/pm case

Open amichair opened this issue 12 years ago • 7 comments

The current documentation for the date filter is inconsistent about the case of the 'a' AM/PM format - the output is uppercase, but the docs mostly show lowercase, which is misleading. Other than fixing the docs, it would be great to actually support the two different formatting options, e.g. 'a' for uppercase and 'A' for lowercase (the inverse would be more intuitive, but 'a' is already used for uppercase, so for backward compatibility's sake... or just use a different letter for lowercase).

amichair avatar Aug 25 '14 14:08 amichair

Would you like to submit a PR for this? :D

btford avatar Aug 25 '14 19:08 btford

@btford This information is picked from the CLDR that

  • Already defines the format using 'a' for the AMPMS symbol
  • Does not have a lower case version of AMPMS

I am not sure what are the document issues, keeping this issue open to get more information on this last part

lgalfaso avatar Aug 29 '14 08:08 lgalfaso

The documentation issues are the ones fixed in #8780 above, i.e. that all examples show lowercase am/pm whereas the actual format is uppercase.

amichair avatar Aug 29 '14 09:08 amichair

@amichair thanks, landed as 7a36d4953316a1833bcd787c5763d0cc78eb0b1e

lgalfaso avatar Aug 29 '14 11:08 lgalfaso

Thanks @SekibOmazic for actually doing it :-)

amichair avatar Aug 29 '14 12:08 amichair

You can use lowercase filter after date to convert am/pm to lowercase.

For example: 1288323623006 | date: "h:mma" | lowercase will produce "5:40am"

Although I agree with you that a/A notations would be much better.

markogresak avatar Sep 30 '16 14:09 markogresak

It is also possible to inject and modify $locale service: $locale.DATETIME_FORMATS.AMPMS = ['am', 'pm']; See plunker: https://plnkr.co/edit/a49kjvOdifXPAvBlmXEi?p=preview

andriy101 avatar Dec 20 '17 08:12 andriy101