Skip to content

Incorrect date parsing for year 1-999 #9230

Closed

Description

@a88zach

Issue Description

There is an edge case with very early years where the date parsing logic is incorrect. The code here does not handle years 1-999 correctly: https://github.com/typeorm/typeorm/blob/51b2a63d/src/util/DateUtils.ts#L25

As an example, if the date stored in the database is 0202-01-01 which is a valid date, the output from parsing will be 202-01-01. This format breaks validation when returning a response if validation requires a valid ISO date format

Expected Behavior

A date from year 1 to year 999 should contain a leading 0 when parsed from the database

Actual Behavior

The leading 0 is being stripped from the date

Additional Context

Relevant Database Driver(s)

DB Type Reproducible
aurora-mysql no
aurora-postgres no
better-sqlite3 no
cockroachdb no
cordova no
expo no
mongodb no
mysql no
nativescript no
oracle no
postgres yes
react-native no
sap no
spanner no
sqlite no
sqlite-abstract no
sqljs no
sqlserver no

Are you willing to resolve this issue by submitting a Pull Request?

  • ✅ Yes, I have the time, and I know how to start.
  • ✖️ Yes, I have the time, but I don't know how to start. I would need guidance.
  • ✖️ No, I don’t have the time, but I can support (using donations) development.
  • ✖️ No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.

Activity

  1. added a commit that references this issue on Jul 22, 2022
    12842e0
  2. added a commit that references this issue on Aug 24, 2022
    72a0147
  3. added a commit that references this issue on Aug 25, 2022
    ffed0c7
  4. added a commit that references this issue on Aug 29, 2022
    ab340b4
  5. added a commit that references this issue on Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions