carrylex@lemmy.world to Programmer Humor@programming.dev · 4 months agoImplementing RFC 3339 shouldn't really be that hard...lemmy.worldimagemessage-square62fedilinkarrow-up1659file-text
arrow-up1659imageImplementing RFC 3339 shouldn't really be that hard...lemmy.worldcarrylex@lemmy.world to Programmer Humor@programming.dev · 4 months agomessage-square62fedilinkfile-text
minus-squarecarrylex@lemmy.worldOPlinkfedilinkarrow-up32·4 months agoSo just for additional context: This meme was brought to you by the following API response scheme: { "time": "2007-12-24 18:12", "servertimezone": "Europe/Vienna", "timezoneoffset": -8 } when it could have just been { "date": "2007-12-24T18:21:00-07:00" }
minus-squaregjoel@programming.devlinkfedilinkarrow-up8·4 months agoTo be fair, returning the actual timezone (as defined by tz.db) is useful if you don’t just want the current time since you’ll be able to take DST into account. Not sure how Vienna is -8 though, it should be +1 (or 2 depending on DST).
minus-squarecarrylex@lemmy.worldOPlinkfedilinkarrow-up3·edit-24 months agoJust for further clarification, the API works like this: time is the local (client) time (in this case UTC-7) servertimezone is the time zone where the server is located timezoneoffset is the offset of the local time relative to the servertimezone (offset from the servers PoV) To get the UTC date you have to do something like this: time.minusHours(timezoneoffset).atZone(servertimezone).toUTC()
So just for additional context:
This meme was brought to you by the following API response scheme:
{ "time": "2007-12-24 18:12", "servertimezone": "Europe/Vienna", "timezoneoffset": -8 }
when it could have just been
{ "date": "2007-12-24T18:21:00-07:00" }
To be fair, returning the actual timezone (as defined by tz.db) is useful if you don’t just want the current time since you’ll be able to take DST into account. Not sure how Vienna is -8 though, it should be +1 (or 2 depending on DST).
Just for further clarification, the API works like this:
time
is the local (client) time (in this case UTC-7)servertimezone
is the time zone where the server is locatedtimezoneoffset
is the offset of the local time relative to the servertimezone (offset from the servers PoV)To get the UTC date you have to do something like this:
time.minusHours(timezoneoffset).atZone(servertimezone).toUTC()