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: update date utils to parse year correctly for years 1-999 #9236

Merged
merged 3 commits into from
Aug 24, 2022

Conversation

a88zach
Copy link
Contributor

@a88zach a88zach commented Jul 22, 2022

Description of change

Update DateUtils to correctly handle years less than 999. For instance, a date of 0999-01-01 should parse to the same string value with a leading 0 for the year. Previously, the output would not contain the leading 0.

Fixes: #9230

Pull-Request Checklist

  • Code is up-to-date with the master branch
  • npm run format to apply prettier formatting
  • npm run test passes with this change
  • This pull request links relevant issues as Fixes #0000
  • There are new or updated unit tests validating the change
  • Documentation has been updated to reflect this change
  • The new commits follow conventions explained in CONTRIBUTING.md

src/util/DateUtils.ts Outdated Show resolved Hide resolved
*/
private static formatZerolessValue(value: number): string {
if (value < 10) return "0" + value
private static formatZerolessValue(value: number, totalLength = 2): string {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

@pleerock pleerock merged commit 72a0147 into typeorm:master Aug 24, 2022
@pleerock
Copy link
Member

Thank you for contribution! 🎉

wirekang pushed a commit to wirekang/typeorm that referenced this pull request Aug 25, 2022
…rm#9236)

* fix: update date utils to parse year correctly for years 1-999

Closes: typeorm#9230

* fix: commit change to date utils

* fix: default total length to 2
nordinh pushed a commit to nordinh/typeorm that referenced this pull request Aug 29, 2022
…rm#9236)

* fix: update date utils to parse year correctly for years 1-999

Closes: typeorm#9230

* fix: commit change to date utils

* fix: default total length to 2
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

Successfully merging this pull request may close these issues.

Incorrect date parsing for year 1-999
3 participants