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: cleanup date helpers #10877

Open
2 of 22 tasks
emersion opened this issue Feb 20, 2025 · 0 comments
Open
2 of 22 tasks

front: cleanup date helpers #10877

emersion opened this issue Feb 20, 2025 · 0 comments
Assignees
Labels
area:front Work on Standard OSRD Interface modules kind:enhancement Improvement of existing features

Comments

@emersion
Copy link
Member

emersion commented Feb 20, 2025

Description and goal

We have a bunch of helpers in utils/date and utils/timeManipulation. Some of these are buggy, some could improved to be more type-safe, some are overlapping in functionality, and they all could be tweaked to be more consistent.

I've been working on this for a while already, this issue is about the remaining work.

utils/date

  • timestampToHHMMSS(): can be replaced by dateToHHMMSS(), which is more type-safe (front: improve OperationalPointWithTimeAndSpeed type safety, drop timestampToHHMMSS() #10876)
  • formatIsoDate(): should be replaced with something working with local dates
  • Revamp/unify date formatting utils:
    • dateTimeFormatting()
    • formatDay()
    • formatDateToString() and extractDateAndTime()
    • serializeDateTimeWithoutYear()
    • formatDateString()
    • dateToHHMMSS()
    • dateToDDMMYYYY()
    • formatToIsoDate() (front: drop formatToIsoDate() #10845)
  • formatLocaleDateToIsoDate(): should be dropped, replaced by Date.toISOString()
  • isoDateToMs(): should be dropped (front: drop formatToIsoDate() #10845)
  • isoDateWithTimezoneToSec(): should be dropped
  • formatDateForInput(): should be replaced with something similar to formatLocalDateTime()
  • convertUTCDateToLocalDate(): should be dropped
  • generateISODateFromDateTime(): needs investigation? (mutates input arg, awkward API)
  • formatLocaleDate(): should be dropped, buggy (front: fix isEqualDate() #10846)
  • formatTimeDifference(): should be moved to Duration?

utils/timeManipulation

  • sec2ms(), ms2sec(), minToMs(), durationInSeconds(), calculateTimeDifferenceInDays(), secToMin(), SECONDS_IN_A_DAY: should be replaced by Duration
  • datetime2time(), time2datetime(), sec2datetime(), secToHoursString(): weird to use d3 for this, overlaps with time formatting helpers from utils/date? (front: drop TimeButtons, TrainDetails and ChartSynchronizer #10881)
  • sec2time(): uses UTC instead of local time?

Acceptance criteria

.

@emersion emersion added area:front Work on Standard OSRD Interface modules kind:enhancement Improvement of existing features labels Feb 20, 2025
@emersion emersion self-assigned this Feb 20, 2025
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 kind:enhancement Improvement of existing features
Projects
None yet
Development

No branches or pull requests

1 participant