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

"yyyyy" is not supported #150

Closed
Waize opened this issue Jun 11, 2020 · 2 comments
Closed

"yyyyy" is not supported #150

Waize opened this issue Jun 11, 2020 · 2 comments

Comments

@Waize
Copy link

Waize commented Jun 11, 2020

First of all: your library works great!

Sadly one Edge-Case does not work:

import moment from "moment-timezone";
import "@rangerrick/moment-javaformat";
...
  let date = moment("2000");
  return date.formatJavaSDF("yyyyy"); // should be 02000

See Java-Examples: https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html.

The following error occured with the code snipped:

Error: 'yyyyy' cannot be converted to a moment format token; unknown token
	    at t.value (src/test/frontend/tests.bundle.js:9437:10016)
	    at x.e.fn.formatJavaSDF (src/test/frontend/tests.bundle.js:9437:3745)
	    at t.a (src/test/frontend/tests.bundle.js:9573:309)
	    at src/test/frontend/tests.bundle.js:10851:3660
	    at Array.map (<anonymous>)
	    at Context.<anonymous> (src/test/frontend/tests.bundle.js:10851:3625)

After fiddle around a bit, some further Formatter will not work: F and W.

@RangerRick
Copy link
Owner

F and W in SimpleDateFormat are known broken and very difficult to implement in a sane way. I should document that somewhere other than the unit tests. :)

As for yyyyy not working, I only did support for up to 4 entries as that's what's shown in the official javadoc for SDF and DTF. I've gone ahead and created test data for 1-6 entries, and made everything work now. I'll put out a 1.0.3 release with these fixes as soon as I get the chance.

@RangerRick
Copy link
Owner

OK, 1.0.3 is out, assuming it has made its way through caches. Let me know if you hit any issues.

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