this post was submitted on 28 Jun 2023
19 points (100.0% liked)
cybersecurity
3227 readers
5 users here now
An umbrella community for all things cybersecurity / infosec. News, research, questions, are all welcome!
Community Rules
- Be kind
- Limit promotional activities
- Non-cybersecurity posts should be redirected to other communities within infosec.pub.
Enjoy!
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
What time format are you using? 64 bit Unix and date time strings should be easy to parse. Just a simple new Date(x).toLocaleString()
It's not that simple. Parsing isn't a problem, it's formatting with a timezone that sucks. It's a pinch point in a lot of different ways. Because MomentJS is in maintenance mode and the Temporal library isn't ready yet, I tried to do it in vanilla JS. Date objects don't do a good job of keeping track of timezone. You can only apply the timezone when converting the Date object to a string with
.toLocaleString(locale, {timeZone: "America/New_York"})
and the formatting rules available are not capable of producing the desired not-quite-ISO8601Nanos timestamp (I don't want it to be in UTC, I want that layout with a trailing timezone offset). I fell back to moment but moment-timezone doesn't work well with the Jest tests as they're written. I plan to rewrite a lot when the Temporal library is prod ready but that won't be before this sprint is over.