Add date time format utilities
What does this MR do?
This adds a few date time formatting utils that will be used when we implement the DAST scans scheduler in !67583 (merged). For the sake of keeping the feature MR as small as possible, these utils have been moved to a separate MR.
-
stripTimezoneFromISODate
will be used to reset the date and time inputs to the correct values when initializing the form with a stored datetime. We need this because the datetime will be stored with the timezone offset included (eg.2021-08-16T16:00+02:00
). However, in the form, the timezone and the date are defined in separate fields, so we cannot instantiate aDate
instance directly from the stored date. If we did, the browser would compute the offset relative to the user's timezone, which would result in incorrect values being set in the date and time inputs. -
dateAndTimeToUTCString
combines a date and a time and returns the computed Date's ISO string representation. That's the value that we'll send to the backend as part of the GraphQL mutation. -
dateToTimeInputValue
will serve to restore a time input's value from a Date instance.
Related to #328752 (closed)
Edited by Paul Gascou-Vaillancourt