Skip to content

[JS] the replace statement in parseDate is too greedy #8632

@tray2100

Description

@tray2100
Description

Currently in the parseDate() function it uses replace('/T/', ' ') to convert date strings into something that the Date class can use for construction. This works well for ISO_8601 date strings but it also has the side effect of ruining date strings that have GMT in it.

openapi-generator version

5.0.0

Suggest a fix/enhancement

Current:

new Date(str.replace(/T/i, ' ')) => Wed Apr 15 2020 00:00:00 GM -0700 (Pacific Daylight Time)

Fix:

new Date(str.replace(/(\d)(T)(\d)/i, '$1 $3')) => Wed Apr 15 2020 00:00:00 GMT-0700 (Pacific Daylight Time)

This allows GMT based date strings to work without issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions