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

fix: date parsing errors #67 #68

Merged

Conversation

lamweili
Copy link
Collaborator

@lamweili lamweili commented May 31, 2022

before

const format = require('date-format');
const endOfMonth = function() {
  return new Date("2022-05-31T00:00:00.000Z");
};
format.parse('yyyy-MM-dd', '2022-01-01', endOfMonth()); // 2022-01-01T00:00:00.000Z
format.parse('yyyy-MM-dd', '2022-02-01', endOfMonth()); // 2022-03-01T00:00:00.000Z  << wrong month
format.parse('yyyy-MM-dd', '2022-03-01', endOfMonth()); // 2022-03-01T00:00:00.000Z
format.parse('yyyy-MM-dd', '2022-04-01', endOfMonth()); // 2022-05-01T00:00:00.000Z  << wrong month
format.parse('yyyy-MM-dd', '2022-05-01', endOfMonth()); // 2022-05-01T00:00:00.000Z
format.parse('yyyy-MM-dd', '2022-06-01', endOfMonth()); // 2022-07-01T00:00:00.000Z  << wrong month
format.parse('yyyy-MM-dd', '2022-07-01', endOfMonth()); // 2022-07-01T00:00:00.000Z
format.parse('yyyy-MM-dd', '2022-08-01', endOfMonth()); // 2022-08-01T00:00:00.000Z
format.parse('yyyy-MM-dd', '2022-09-01', endOfMonth()); // 2022-10-01T10:02:37.851Z  << wrong month
format.parse('yyyy-MM-dd', '2022-10-01', endOfMonth()); // 2022-10-01T00:00:00.000Z
format.parse('yyyy-MM-dd', '2022-11-01', endOfMonth()); // 2022-12-01T00:00:00.000Z  << wrong month
format.parse('yyyy-MM-dd', '2022-12-01', endOfMonth()); // 2022-12-01T00:00:00.000Z

after

const format = require('date-format');
const endOfMonth = function() {
  return new Date("2022-05-31T00:00:00.000Z");
};
format.parse('yyyy-MM-dd', '2022-01-01', endOfMonth()); // 2022-01-01T00:00:00.000Z
format.parse('yyyy-MM-dd', '2022-02-01', endOfMonth()); // 2022-02-01T00:00:00.000Z
format.parse('yyyy-MM-dd', '2022-03-01', endOfMonth()); // 2022-03-01T00:00:00.000Z
format.parse('yyyy-MM-dd', '2022-04-01', endOfMonth()); // 2022-04-01T00:00:00.000Z
format.parse('yyyy-MM-dd', '2022-05-01', endOfMonth()); // 2022-05-01T00:00:00.000Z
format.parse('yyyy-MM-dd', '2022-06-01', endOfMonth()); // 2022-06-01T00:00:00.000Z
format.parse('yyyy-MM-dd', '2022-07-01', endOfMonth()); // 2022-07-01T00:00:00.000Z
format.parse('yyyy-MM-dd', '2022-08-01', endOfMonth()); // 2022-08-01T00:00:00.000Z
format.parse('yyyy-MM-dd', '2022-09-01', endOfMonth()); // 2022-09-01T00:00:00.000Z
format.parse('yyyy-MM-dd', '2022-10-01', endOfMonth()); // 2022-10-01T00:00:00.000Z
format.parse('yyyy-MM-dd', '2022-11-01', endOfMonth()); // 2022-11-01T00:00:00.000Z
format.parse('yyyy-MM-dd', '2022-12-01', endOfMonth()); // 2022-12-01T00:00:00.000Z

@lamweili lamweili added the bug Something isn't working label May 31, 2022
@lamweili lamweili added this to the 4.0.11 milestone May 31, 2022
@lamweili lamweili linked an issue May 31, 2022 that may be closed by this pull request
@lamweili lamweili merged commit 06b887c into master May 31, 2022
@lamweili lamweili deleted the 67-formatparse-fails-when-current-date-is-31st-of-some-month branch May 31, 2022 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

format.parse fails when current date is 31st of some month
1 participant