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: use Date instead of string in OsrdConfState.startTime #9954

Merged
merged 4 commits into from
Dec 20, 2024

Conversation

emersion
Copy link
Member

@emersion emersion commented Dec 5, 2024

See individual commits.

Improves type safety.

@github-actions github-actions bot added the area:front Work on Standard OSRD Interface modules label Dec 5, 2024
@emersion emersion self-assigned this Dec 5, 2024
@emersion emersion force-pushed the emr/compute-op-schedules-date branch from d0a78a8 to 590695a Compare December 5, 2024 14:36
@emersion emersion marked this pull request as ready for review December 5, 2024 14:53
@emersion emersion requested a review from a team as a code owner December 5, 2024 14:53
Copy link
Contributor

@clarani clarani left a comment

Choose a reason for hiding this comment

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

Nice cleaning !! Thanks !

Found a bug:

  • when editing a train, the date is not displayed

Copy link
Contributor

@RomainValls RomainValls left a comment

Choose a reason for hiding this comment

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

LGTM (except for the bug mentioned by @clarani), tested ✅

@emersion
Copy link
Member Author

Ooops, sounds like formatLocalDateTime() was using a bad format string. Fixed:

 export const formatLocalDateTime = (date: Date) =>
-  dayjs(date).local().format('YYYY-MM-DDTHH:MM:SS');
+  dayjs(date).local().format('YYYY-MM-DDTHH:mm:ss');

@emersion emersion requested a review from clarani December 10, 2024 13:08
@emersion emersion force-pushed the emr/compute-op-schedules-date branch from 590695a to dc40969 Compare December 10, 2024 13:08
@emersion emersion force-pushed the emr/compute-op-schedules-date branch from dc40969 to 5b07ebf Compare December 20, 2024 11:01
Improves type safety.

While at it, fix a small typo: s/substractTo/subtractFrom/

Signed-off-by: Simon Ser <contact@emersion.fr>
Improves type safety.

Signed-off-by: Simon Ser <contact@emersion.fr>
Improves type safety.

Previously, it was important for OsrdConfState.startTime to be in
a specific timezone, because the string was later truncated and
directly used on an datetime-local form input. This patch improves
robustness by converting to the local timezone right before feeding
the value to the datetime-local form input, making it so a different
timezone in OsrdConfState.startTime doesn't break the app.

IsoDateTimeString is not longer used and can be dropped.

Signed-off-by: Simon Ser <contact@emersion.fr>
startTime should be used instead, because it's an already-parsed
Date object instead of a string.

Signed-off-by: Simon Ser <contact@emersion.fr>
@emersion emersion force-pushed the emr/compute-op-schedules-date branch from 5b07ebf to 252b871 Compare December 20, 2024 11:22
Copy link
Contributor

@clarani clarani left a comment

Choose a reason for hiding this comment

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

LGTM, tested ✅

@emersion emersion added this pull request to the merge queue Dec 20, 2024
Merged via the queue into dev with commit cfe0567 Dec 20, 2024
27 checks passed
@emersion emersion deleted the emr/compute-op-schedules-date branch December 20, 2024 12:28
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