question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

parse with format "yyMd" gives unexpected result

See original GitHub issue

I’m unsure if my expectations are off but when I parse the string “2211” and “2212” using format “yyMd” I don’t get a valid date. “2213” works.

  const actualDate = parse("2211", "yyMd", new Date());
  console.log(actualDate.toString());
  //Invalid Date

  const expectedDate = new Date("2022-01-01");
  console.log(expectedDate.toString());
  //Sat Jan 01 2022 01:00:00 GMT+0100 (Central European Standard Time)

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
Alanscutcommented, Mar 30, 2022

my point is this is just an accepted side effect of using a “fuzzy” format like yyMd, this is just my personal opinion,maybe we should @ the member of this lib to confirm the situation

1reaction
nicklasisraelssoncommented, Mar 23, 2022

Yeah I agree that the yyMd format is probably prone to these errors.

I was however surprised that parse rather choose to return an invalid date since it can match 11 to a month with no day and didn’t try matching the 11 to January 1st.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SimpleDateFormat: unexpected results and unexpected parse ...
I'm having huge difficulties with simple date format. First of all, I know not all tutorials on all sites are actually good, but...
Read more >
HDATE: Converting the Date Portion of a Date-Time Value to ...
The HDATE function converts the date portion of a date-time value to the date format YYMD. You can then convert the result to...
Read more >
DateTime.Parse Method (System) - Microsoft Learn
Converts the string representation of a date and time to its DateTime equivalent by using culture-specific format information and a formatting style. Examples....
Read more >
TIBCO FOCUS® Developing Applications Release 9.0.0
Enables use of blank delimited (Fusion) Master File syntax, and provides increased ... dates with YMD or YYMD format; or January 1901, for....
Read more >
Date Parsing - Kendo UI Globalization - Documentation
This may lead to unexpected results when parsing ambiguous date strings with no delimiters. For example, the parsing of 222015 with a dMyyyy...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found