Skip to content
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

dateFormatter does not recognise skeleton with EEEE #455

Closed
murdockcrc opened this issue Jun 18, 2015 · 5 comments
Closed

dateFormatter does not recognise skeleton with EEEE #455

murdockcrc opened this issue Jun 18, 2015 · 5 comments

Comments

@murdockcrc
Copy link

Hi,

I have a date represented by the milliseconds figure and would like to get the full name of the Day that date corresponds to.

I have tried the following, but it seems like skeleton does not recognize the formatter 'EEEE', which is correct from the standard's perspective:

var dateFormatOptions = {skeleton: 'EEEE'};
var deFormatter = Globalize('de').dateFormatter(dateFormatOptions);

This fails with the exception 'E_UNSUPPORTED: Unsupported {"feature":"year pattern u"}'

However, this code does work as expected and returns the full name of the day:

    var dateFormatOptions = {raw: 'EEEE'};
    var deFormatter = Globalize('de').dateFormatter(dateFormatOptions);
@rxaviers
Copy link
Member

You may have noticed {skeleton: 'E'} works just fine. But, {skeleton: 'EEEE'} doesn't. The former shall work when #271 is implemented.

Having said that, your issue shows we should have a better error message for such cases. Therefore, I'm keeping this bug opened until we improve the error message. Specifically, https://github.com/jquery/globalize/blob/master/src/date.js#L64 returns undefined, which in turn is passed as the expanded-pattern to the formatter, which in turn tries to recognize u and fails.

Having said all that, you can use {raw: 'EEEE'} just fine for your use case. Because, you are formatting only one single field. Please, just let me know on any questions.

@rxaviers
Copy link
Member

@murdockcrc
Copy link
Author

@rxaviers Thanks for the quick reply.

I guess my expectation was for 'skeleton' to work and recognise the formatting characters as specified in the standard (http://userguide.icu-project.org/formatparse/datetime). If this is not the case, then I hope that using raw with the standard's formatting parameters is OK. I say this because the documentation explicitly discourages the use of raw and instead recommends skeleton.

@rxaviers
Copy link
Member

guess my expectation was for 'skeleton' to work and recognise the formatting characters as specified in the standard (http://userguide.icu-project.org/formatparse/datetime)

#271

@rxaviers
Copy link
Member

Closing this issue in favor of #271 (about deducing skeletons like EEEE) + #469 (about improving the error message for undefined skeletons).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants