Skip to content

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

Merged
pleerock merged 3 commits into
typeorm:masterfrom
a88zach:issue-9230
Aug 24, 2022
Merged

pleerock merged 3 commits into
typeorm:masterfrom
a88zach:issue-9230

Conversation

@a88zach

@a88zach a88zach commented Jul 22, 2022 •

Copy link
Copy Markdown
Contributor

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

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

Copy link
Copy Markdown

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
Copy Markdown
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

Development

Successfully merging this pull request may close these issues.

Incorrect date parsing for year 1-999

3 participants