Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix(dateFilter): ignore era format specifier "G" #10543

Closed

Conversation

petebacondarwin
Copy link
Contributor

The era format specifier is not supported in our locale code and is being
passed through as the letter G in some long date formats, such as Thai (th-th).

It is not straightforward to provide locale specific era formatting since
the logic is calendar (locale) specific and not provided by the Google
closure library.

This commit simply ignores the G in format strings until we can work out
a better strategy for dealing with eras.

Closes #10503

The era format specifier is not supported in our locale code and is being
passed through as the letter G in some long date formats, such as Thai (th-th).

It is not straightforward to provide locale specific era formatting since
the logic is calendar (locale) specific and not provided by the Google
closure library.

This commit simply ignores the G in format strings until we can work out
a better strategy for dealing with eras.

Closes angular#10503
@lgalfaso
Copy link
Contributor

@petebacondarwin era is part of Google closure, if we are adding the token G then we should also do the steps to add era to the locales and parse them appropriately (this is, only for the Gregorian calendar)

@petebacondarwin
Copy link
Contributor Author

Google closure does not indicate which calendar a locale uses so we can't
do that
On 22 Dec 2014 20:54, "Lucas Galfasó" notifications@github.com wrote:

@petebacondarwin https://github.com/petebacondarwin era is part of
Google closure, if we are adding the token G then we should also do the
steps to add era to the locales and parse them appropriately (this is,
only for the Gregorian calendar)


Reply to this email directly or view it on GitHub
#10543 (comment).

@lgalfaso
Copy link
Contributor

Google closure uses Gregorian calendar for all locales, if they do not, it is a bug

@lgalfaso
Copy link
Contributor

Google closure is using the Gregorian calendar, but using the same logic,
it does not specify the calendar when specifying the months names...

@petebacondarwin
Copy link
Contributor Author

I am not sure what you are suggesting.

The problem, as I see it, is that some locales do not use the Gregorian calendar and so they use different logic to specify the current era. For instance, in Thailand they use the Buddhist Era (B.E.), which is 543 years greater than Anno Domimi (A.D.) Since the Google Closure data does include Era characters but doesn't include the calendar then it is not possible to infer the era that should be displayed for a given date.

I think that what you are assuming is that the logic for computing the era is the same for all locales, in which case we would have been able to generate locale specific date strings that include the era. But this is not the case.

@lgalfaso
Copy link
Contributor

what I am saying is that dateFilter is a filter that outputs in Gregorian calendar always. If in Thailand the Buddhist calendar is used, that is not a problem that dateFilter should take care about.

Now, about the remark on months, all the current built-in locales include the months names for the Gregorian calendar and for the Gregorian calendar only. I see no issue is adding the era name as it is adding information that should only be used to calculate the era on a date using the Gregorian calendar. Just like the months information, this is only good to know the month names in the Gregorian calendar. The Buddhist calendar month names are not the same as Gregorian calendar months names, and this does not prevent us from adding the months names to the locales

@petebacondarwin
Copy link
Contributor Author

OK, I take it back - I didn't realise that the Thai era names in the Google Closure library are actually just translations of BC and AD. So indeed we should include the era data in our locale files.

@petebacondarwin petebacondarwin deleted the date-era-issue-10503 branch November 24, 2016 09:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

angular-i18n has wrong dateformat in Thai.
3 participants