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

Format date as day and full month #461

Closed
vectart opened this issue Jul 14, 2015 · 2 comments
Closed

Format date as day and full month #461

vectart opened this issue Jul 14, 2015 · 2 comments

Comments

@vectart
Copy link

vectart commented Jul 14, 2015

I'm trying to format a date in German locale, so in result I have 5 Oktober.

That works fine:

.dateFormatter({ skeleton: 'Md' })(new Date('2015-10-05'))
// "5.10."
.dateFormatter({ skeleton: 'MMd' })(new Date('2015-10-05'))
// "5.10."
.dateFormatter({ skeleton: 'MMMd' })(new Date('2015-10-05'))
// "5. Okt."

That fails:

.dateFormatter({ skeleton: 'MMMMd' })(new Date('2015-10-05'))
/*
Uncaught Error: E_UNSUPPORTED: Unsupported {"feature":"year pattern `u`"}.
    at createError (http://10.3.220.169:8002/vendor/globalize/dist/globalize.js:105:10)
    at createErrorUnsupportedFeature (http://10.3.220.169:8002/vendor/globalize/dist/globalize/number.js:52:9)
    at http://10.3.220.169:8002/vendor/globalize/dist/globalize/date.js:646:11
    at String.replace (native)
    at dateFormatProperties (http://10.3.220.169:8002/vendor/globalize/dist/globalize/date.js:604:10)
    at Globalize.dateFormatter.Globalize.dateFormatter [as dateFormatter] (http://10.3.220.169:8002/vendor/globalize/dist/globalize/date.js:1749:15)
*/

Nonetheless, Finnish locale gives expected result:

.dateFormatter({ skeleton: 'MMMd' })(new Date('2015-10-05'))
// "5. lokakuuta"

How to get 5 Oktober in de locale?

@rxaviers
Copy link
Member

The correct solution is to get #271 implemented. Contribution is highly appreciated. ✅

A workaround would be to specify the raw format (recommended for machine parsing only, not for your purposes though): {raw: "d. MMMM"}

Globalize( "de" ).dateFormatter({ raw: "d. MMMM" })( new Date( "2015-10-05" ) );
// > '4. Oktober'

@rxaviers
Copy link
Member

rxaviers commented Aug 4, 2015

Closing as duplicate of #271.

@rxaviers rxaviers closed this as completed Aug 4, 2015
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