In what timezone is this okay?
-
@GuyWhoKilledBear said in In what world is this okay?:
I'd say the guy should learn to code, except that things routinely go wrong when programmers fuck up dates.
Fo shizzle. Spent most of the afternoon trying to fix a timezone problem that was causing an off by one day error.
My front end would sent a date as
yyyy-mm-dd
and the server would deserialize it as2021-03-01 99:00:00 UTC
, then convert to EST and get saved in the DB as2021-02-28 19:00:00
. An awful confluence of multiple technologies handling things slightly differently, plus we're lazy and don't store our dates or times with any timezone info, which usually doesn't matter
-
@boomzilla said in In what world is this okay?:
yyyy-mm-dd and the server would deserialize it as 2021-03-01 99:00:00 UTC
:well_there's_your_problem.pptx:
-
@izzion well, quite. But...how to solve it? I said fuck it and just adjusted the
shittimezone out of it.EDIT: Oh, or maybe you were referring to my typo of
99
instead of19
.
-
@boomzilla said in In what world is this okay?:
@izzion well, quite. But...how to solve it? I said fuck it and just adjusted the
shittimezone out of it.EDIT: Oh, or maybe you were referring to my typo of
99
instead of19
.If your server is deserializing a timeless date to 99h, then something's REALLY wrong.
If it's deserializing to anything other than 00h UTC or 00h <server's local timezone> (which should be UTC anyway if your system is in cloud or even mildly potentially multi-regional), there's something mildly wrong.
But yes, I was mostly lampooning your tyop.
-
@izzion said in In what world is this okay?:
If it's deserializing to anything other than 00h UTC or 00h <server's local timezone> (which should be UTC anyway if your system is in cloud or even mildly potentially multi-regional), there's something mildly wrong
The servers are basically guaranteed to be set to Eastern time (even when we fail back and they're physically in Mountain time). We do have stuff that goes on in Mountain time, and the time has kind of come when we need to be at least a little bit TZ aware. In the past it wasn't a problem because stuff that happened in either TZ didn't affect anything in another, so we could just cover our ears and pretend that times were all "local" for whatever that meant.
But also, using Angular on the front end is new and we hadn't had this particular problem before. It's odd, and I need to look at another part of the system (which hasn't gone to production yet, so at least there's that) that uses dates to see if it's doing this as well, but I have several fires to get through before I can take a look.
-
@boomzilla said in In what timezone is this okay?:
<abbr title="UDT-5">EST</abbr>
UDT-5?
What are you working with again? Actually, on second thought, don't answer that.
-
@boomzilla said in In what timezone is this okay?:
@izzion said in In what world is this okay?:
If it's deserializing to anything other than 00h UTC or 00h <server's local timezone> (which should be UTC anyway if your system is in cloud or even mildly potentially multi-regional), there's something mildly wrong
The servers are basically guaranteed to be set to Eastern time (even when we fail back and they're physically in Mountain time). We do have stuff that goes on in Mountain time, and the time has kind of come when we need to be at least a little bit TZ aware. In the past it wasn't a problem because stuff that happened in either TZ didn't affect anything in another, so we could just cover our ears and pretend that times were all "local" for whatever that meant.
But also, using Angular on the front end is new and we hadn't had this particular problem before. It's odd, and I need to look at another part of the system (which hasn't gone to production yet, so at least there's that) that uses dates to see if it's doing this as well, but I have several fires to get through before I can take a look.
Yeah, there're definitely differences between how JavaScript objects/frameworks handle "naked" dates vs how CLR languages do. Depending on how the data is coming back from the JavaScript and what data type/class is being used on the CLR side to translate to the server, there are ways to control the time-zone auto translation that happens in the back-end code, but it definitely gets pretty horky pretty quickly.
-
@cvi said in In what timezone is this okay?:
What are you working with again?
Short answer: Typing while frustrated.
Longer answer: mixing up
UTC-X
andEST
vsEDT
in my head.
-
@izzion said in In what timezone is this okay?:
@boomzilla said in In what timezone is this okay?:
@izzion said in In what world is this okay?:
If it's deserializing to anything other than 00h UTC or 00h <server's local timezone> (which should be UTC anyway if your system is in cloud or even mildly potentially multi-regional), there's something mildly wrong
The servers are basically guaranteed to be set to Eastern time (even when we fail back and they're physically in Mountain time). We do have stuff that goes on in Mountain time, and the time has kind of come when we need to be at least a little bit TZ aware. In the past it wasn't a problem because stuff that happened in either TZ didn't affect anything in another, so we could just cover our ears and pretend that times were all "local" for whatever that meant.
But also, using Angular on the front end is new and we hadn't had this particular problem before. It's odd, and I need to look at another part of the system (which hasn't gone to production yet, so at least there's that) that uses dates to see if it's doing this as well, but I have several fires to get through before I can take a look.
Yeah, there're definitely differences between how JavaScript objects/frameworks handle "naked" dates vs how CLR languages do. Depending on how the data is coming back from the JavaScript and what data type/class is being used on the CLR side to translate to the server, there are ways to control the time-zone auto translation that happens in the back-end code, but it definitely gets pretty horky pretty quickly.
E_NOPE_THREAD_IS_ARROWS
Uh. Definitely no CLR involved anywhere. But...we use JSF2 for the "legacy" front end, and it handles all the [de]serialization differently than when you make a REST call using Angular...apparently.
-
@boomzilla What is your session time zone? This is a separate thing from your server time zone. Possibly your previous framework defaulted to server time zone and your current defaults to client OS time zone?
-
@izzion said in In what timezone is this okay?:
how JavaScript objects/frameworks handle "naked" dates
The way that JavaScript's Date object works drives me batty. When initializing a Date object, you put in the year as normal, the day as normal, and the month minus one, because 0 is obviously January. I mean, it's clearly an enum, so of course you start at 0, and of course you don't treat 1 as January, because then you're throwing away a whole enum entry, and who would do that!?
Bah. JavaScript Dates. No wonder there are so many JS date/time libraries.
-
@PotatoEngineer said in In what timezone is this okay?:
The way that JavaScript's Date object works drives me batty.
For a bit I thought you said Java Date objects, which are at least as crazy/bad, but at least those are largely replaced now.
-
@PleegWat said in In what timezone is this okay?:
@boomzilla What is your session time zone? This is a separate thing from your server time zone. Possibly your previous framework defaulted to server time zone and your current defaults to client OS time zone?
No, it's nothing like that, which is the sort of stuff I looked at first, in part because the tester who noticed the problem was in Spain. All that was being sent to the server was the date as a string, e.g.,
theDate: '2021-03-02'
.
-
Ugh, date/time handling.
My preferred way of dealing with that these days is just to make all datetime values timestamps (Unix ones normally), which is effectively UTC, and then just have the UI deal with displays.
But when it's a date, that gets annoying. 2021-03-01T00:00Z isn't actually on 2021-03-01 for half the world, so if you let the UI deal with that, you're going to get WTFs like what you report here. If you set a 'pure date' to 12:00 UTC not 00:00 then it's on the right day everywhere, but then if you start trying to do date range queries, you won't get the answer you expect.
My preferred option is that there is no date type - there's either a timestamp, or a range defined by two timestamps. And if your UI knows what time zone it is in it can make a 'day' the appropriate thing, i.e. if a user in CET picks "2nd March 2021 they'll get 2021-03-02T01:00Z to 2021-03-03T01:00Z because they live in UTC+1.
And yes Java Date classes are a WTF but the replacement is so complicated, and there's so much utility code that understands Dates, that their attempts to fix it have arguably made it even worse.
-
@bobjanova said in In what timezone is this okay?:
If you set a 'pure date' to 12:00 UTC not 00:00 then it's on the right day everywhere
Except for New Zealand and some other Pacific islands. Did you know timezones go up to UTC+14?
-
@boomzilla said in In what timezone is this okay?:
But also, using Angular on the front end is new and we hadn't had this particular problem before. It's odd, and I need to look at another part of the system (which hasn't gone to production yet, so at least there's that) that uses dates to see if it's doing this as well, but I have several fires to get through before I can take a look.
LOL, my tester just kicked this back to me, so there's my answer. At least I know how to fix it.
-
@boomzilla this would be easier if the planet was flat
-
@sockpuppet7 because there'd be no world wide web?
-
@boomzilla There would be no time zones, the www would be fine
-
@sockpuppet7 so it would always be noon? Sounds hot.
-
@boomzilla The sun should orbit the earth, that would be a plain surface supported by a space faring giant turtle
-
@sockpuppet7 but that doesn't eliminate timezones.
-
@boomzilla There would be some minor angle difference but we would be all in the same side of the surface. We wouldn't need time zones
That's different from the most popular belief of flat earthers, that I googled and found they still have them, with the sun circling in the sky and illuminating one part of the surface at a time
-
@sockpuppet7 said in In what timezone is this okay?:
@boomzilla The sun should orbit the earth, that would be a
plainplane surface supported by a space faring giant turtleFTFY
-
@sockpuppet7 said in In what timezone is this okay?:
@boomzilla There would be some minor angle difference but we would be all in the same side of the surface. We wouldn't need time zones
We absolutely would.
That's different from the most popular belief of flat earthers, that I googled and found they still have them, with the sun circling in the sky and illuminating one part of the surface at a time
I'm not sure why you think you're disagreeing with me here. Because you're not, except for being wrong about needing time zones.
-
@boomzilla said in In what timezone is this okay?:
@sockpuppet7 said in In what timezone is this okay?:
@boomzilla There would be some minor angle difference but we would be all in the same side of the surface. We wouldn't need time zones
We absolutely would.
That's different from the most popular belief of flat earthers, that I googled and found they still have them, with the sun circling in the sky and illuminating one part of the surface at a time
I'm not sure why you think you're disagreeing with me here. Because you're not, except for being wrong about needing time zones.
News article headline: Are Time Zones Racist?
Filed under: Though something like this was used almost verbatim as a strawman attack by a news network.
-
@boomzilla said in In what timezone is this okay?:
We absolutely would.
Maybe you're just imagining the sun at a difference distance than me or something. The angle difference could make the difference on sunlight minimal:
Why would we want timezones here? Just to annoy programmers?
-
@sockpuppet7 said in In what timezone is this okay?:
The angle difference could make the difference on sunlight minimal:
Have you ever been awake for a whole day and gone outside at different times?
-
@boomzilla said in In what timezone is this okay?:
Have you ever been awake for a whole day and gone outside at different times?
I didn't understand this question
-
It's weird how photorealistic 3D renders can be considering they totally fudge the way light actually works in a dozen different ways.
-
@sockpuppet7 said in In what timezone is this okay?:
@boomzilla said in In what timezone is this okay?:
Have you ever been awake for a whole day and gone outside at different times?
I didn't understand this question
I guess it depends on how far away the sun is. In the Turtle scenario it's much closer than ours is to us.
-
@boomzilla If we want to get rid of timezones, the sun must stay far
-
@boomzilla said in In what timezone is this okay?:
@sockpuppet7 said in In what timezone is this okay?:
The angle difference could make the difference on sunlight minimal:
Have you ever been awake for a whole day and gone outside at different times?
The sun is above the horizon sometimes. It's below the horizon at other times. Geometry dictates, if the
discworld is flat, then the horizon is level with the edge of the disk and the sun being below the horizon anywhere means it's below the horizon everywhere.This is inconsistent with the observation that when the sun is below the horizon here it is well above the horizon in Australia. Hence the fact the sun is at different heights above the horizon in different parts of the world at the same time must be, at least in part, a government conspiracy.
-
@PleegWat said in In what timezone is this okay?:
This is inconsistent with the observation that when the sun is below the horizon here it is well above the horizon in Australia.
Well obviously they're glued to the underside.
-
Anyway, my bank invented new calendar zones:
-
@boomzilla said in In what timezone is this okay?:
We absolutely would
I don't think so, with a flat earth it's sunrise/daytime/night-time everywhere at the same time. Depending how far away the sun is you could get some weird effects, like the sun is much hotter at sunrise/sunset at the edges, and at noon in the middle.
-
FWIW, Discworld had different timezones because the magical field greatly slowed down the speed of light.
-
@coderpatsy said in In what timezone is this okay?:
Discworld had different timezones
At first I read that as "Discourse had different timezones", and wasn't even surprised.
-
@boomzilla once you get a couple years in the field you'll learn how to serialize dates, don't worry.
-
@Gribnit said in In what timezone is this okay?:
@boomzilla once you get a couple years in the field you'll learn how to
serialize datesmake use of your summer interns, don't worry.
-
@Gribnit said in In what timezone is this okay?:
serialize dates
-
@loopback0 said in In what timezone is this okay?:
@Gribnit said in In what timezone is this okay?:
serialize dates
Parallelizing dates is a really bad idea. The threading is very unsafe, unless they're into polyamory.
-
@HardwareGeek said in In what timezone is this okay?:
@loopback0 said in In what timezone is this okay?:
@Gribnit said in In what timezone is this okay?:
serialize dates
Parallelizing dates is a really bad idea. The threading is very unsafe, unless they're into polyamory.
I have an even larger struggle with parallelizing dates. That requires me to have a date. More than one in fact. One is difficult enough, two would be just not possible. Two at the same time? Crazy talk.
-
Fortunately at my company we only make software made to work in my country (we do software for custom brokers and we only make software to deal with our own government's bureaucracy) and my country only has a single time zone with no DST.
-
@magnusmaster said in In what timezone is this okay?:
Fortunately at my company we only make software made to work in my country (we do software for custom brokers and we only make software to deal with our own government's bureaucracy) and my country only has a single time zone with no DST.
Tell me where. Please tell me where. Don't need the city.
-
All this complaining despite time being quite simple still. Imagine the mess once we go interstellar. Relativity is a bitch; I can't imagine the amount of whining at that point.
Filed under: In addition to mocking flat earthers, we'll get to facepalm at the flat spacetimers.
-
@Gribnit Argentina
-
@PotatoEngineer said in In what timezone is this okay?:
The way that JavaScript's Date object works drives me batty. When initializing a Date object, you put in the year as normal, the day as normal, and the month minus one, because 0 is obviously January. I mean, it's clearly an enum, so of course you start at 0, and of course you don't treat 1 as January, because then you're throwing away a whole enum entry, and who would do that!?
Obviously it's a shallower wrapper around libc than we thought. The jolly
struct tm
that has sneered at us from libc ever since a very long time ago does the same thing, because thetm_mon
field is "the number of months since January".
-
@Steve_The_Cynic At least that's documented correctly, and you're given both a parser and a formatter.
-
@dkf iirc, so does the ECMAScript Date, for all the good it does.