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

front: fix isEqualDate() #10846

Merged
merged 1 commit into from
Feb 24, 2025
Merged

front: fix isEqualDate() #10846

merged 1 commit into from
Feb 24, 2025

Conversation

emersion
Copy link
Member

toLocaleString() returns an arbitrary human-readable string. For instance, in France it returns "18/02/2025 13:32:08" and in Korea it returns "2025. 2. 18. 오후 1:32:08".

The string cannot be used for anything else than display. Trying to extract the date from it will not work: substring(0, 10) will give "2025. 2. 1" in Korea (dropping the "8"). As a result, any day with the same first digit will be interpreted as equal.

Fix this by comparing the year, month, and day of the month instead.

toLocaleString() returns an arbitrary human-readable string. For
instance, in France it returns "18/02/2025 13:32:08" and in Korea
it returns "2025. 2. 18. 오후 1:32:08".

The string cannot be used for anything else than display. Trying
to extract the date from it will not work: substring(0, 10) will
give "2025. 2. 1" in Korea (dropping the "8"). As a result, any
day with the same first digit will be interpreted as equal.

Fix this by comparing the year, month, and day of the month instead.

Signed-off-by: Simon Ser <[email protected]>
@emersion emersion requested review from Yohh and SharglutDev February 18, 2025 12:41
@emersion emersion requested a review from a team as a code owner February 18, 2025 12:41
@github-actions github-actions bot added the area:front Work on Standard OSRD Interface modules label Feb 18, 2025
@emersion emersion self-assigned this Feb 18, 2025
Copy link
Contributor

@SharglutDev SharglutDev left a comment

Choose a reason for hiding this comment

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

Good catch, thanks

@emersion emersion mentioned this pull request Feb 20, 2025
22 tasks
@emersion emersion added this pull request to the merge queue Feb 24, 2025
Merged via the queue into dev with commit 21d2dbb Feb 24, 2025
27 checks passed
@emersion emersion deleted the emr/fix-is-eq-date branch February 24, 2025 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:front Work on Standard OSRD Interface modules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants