Email or username:

Password:

Forgot your password?
Darius Kazemi

absolutely fucking cursed

(8 is the number of hours offset my local browser's timezone is from UTC)

25 comments | Expand all CWs
Dolly ✨🌈🔧

@darius Wait.... Am I understanding this correctly:

Depending on the input format, the parsed date will either be UTC or local time????

For real?

Oh no....

Dolly ✨🌈🔧

@darius See, I thought I misunderstood, thinking, "no, it can't possibly be that bad..."

It really is that bad. That's cursed.

Pronouns in BIOS

@darius LOL what the fuck

Darius Kazemi

what if, as a society, we just agreed to not coordinate information across time zones anymore? that would make my life a lot easier

Jonathan

@darius everyone just switch to UTC, sounds good .

eena meena me

@darius when fast travelling becomes environmentally infeasible, and our global communication networks break into local partitions, or warring fractions – we won't have to coördinate any more!

Darius Kazemi

@meena back to bell towers for synchronization!

eena meena me

@darius you arrive at the train station, look at the bell tower, it say Tuesday.

fuckin Tuesday.
It's been Tuesday here for the last 35 years.

you accept it.

VirtualWolf

@darius I've done enough date-related stuff with Javascript both at work and at home that I'm pretty sure I'd have shot myself if I didn't have Moment.js or Luxon tbh.

martin

@darius imagining a library that parses dd/mm/yyyy as gmt and mm/dd/yyyy as pst

Pronouns in BIOS

@darius You'd figure the parse() method could just have an optional argument to define time zone instead of just assuming it based on formatting...?

Darius Kazemi

@hache ahhaha nope. that's what third party libraries are for, I guess

Григорий Клюшников

As a mainly java developer: how on earth could a date parser not take a format specification? Does it, like, guess what the format is?

Darius Kazemi

@grishka It does in fact guess the format if it's not ISO 8601. And since it's guessing, it assumes local time zone. No, there is no way to pass in a UTC offset and say "give me this one".

developer.mozilla.org/en-US/do

Daniel Cassidy 🦌

@grishka @darius Uhh which language do you think JavaScript borrowed its broken Date type from?

Olivier Forget

@darius Yeah def cursed. The MDN docs themselves recommend not using it and suggest using a lib instead.

I've used dayjs with some success:

day.js.org/docs/en/parse/strin

Darius Kazemi

@teleclimber That's the one I use!

Daniel Cassidy 🦌

@darius do not use the JavaScript Date type under any circumstances. It is a fractal of brokenness. Also do not use any library that uses the JavaScript Date type. They might claim not to be broken but they're all broken.

Joel

@darius Like, I know the depths of Javascript's absurdities is infinite, but somehow it still manages to surprise me.

everest

@darius

Go Up