Email or username:

Password:

Forgot your password?
Darius Kazemi

I had to think about a time zone parsing problem for 5 minutes at work and my body was immediately overwhelmed by the need to sleep for an hour.

29 comments
mhoye

@Chronotope @darius Told a class once, there are some classes of software problem where you only have two choices; you dedicate your life to them, or you exclusively use tools made by people who have dedicated their lives to to them. Every other option is a road to madness and agony.

[DATA EXPUNGED]
brennen

@darius a similar cognitive dynamic explains a lot of my relationship to the timing of meetings in a widely-distributed organization.

allison

@darius oh no there was a bug in your time zone code and you ended up napping for -30 minutes :(

Kit Rhett Aultman

@darius I once had to work on a time zone problem. I remember explaining to the boss that time zones are just madness because they define more than a simple GMT offset; they also set your DST dates. And that matters in Arizona, where you're on Mountain time but don't observe DST, except for the Navajo nation, which does. He asked why that was so important, and I noted that tribal lands are over 1/4 the land mass of Arizona. Then he knew my pain.

Darius Kazemi

@roadriverrail I like to point out the 15, 30, and 45 minute offset time zones. Also the fact that any of these rules can change whenever some government body somewhere in the world decides to change them for some reason.

Kit Rhett Aultman

@darius Indeed, those are all also extremely maddening. In my case, this was from before a time when all phones had GPS and there was a problem with DST and intuiting the time zone from the cell network. There are also cities in the US that kinda just declare themselves aligned with a time zone even if not geographically in it, and that's a lot of fun to figure out.

Darius Kazemi

From the official Ruby DateTime docs:

> If you also have to deal with timezones then best of luck - just bear in mind that you'll probably be dealing with local solar times, since it wasn't until the 19th century that the introduction of the railways necessitated the need for Standard Time and eventually timezones.

Friends don't let friends use time zones

Darius Kazemi

There also appear to be.... no unit tests for timezones in Rubylang??? Am I reading this right? They haven't even been touched in ~3 years and most of them are placeholder

github.com/ruby/ruby/tree/mast

Darius Kazemi

There are handful that are for timezone offsets, but for example, DateTime.parse is not tested for things like "PDT" or "GMT" in a string

Darius Kazemi

Normally I'm not a stickler for 100% test coverage but...... this is a stdlib in Ruby? The programming language?

duncan, lord of hell

@darius *looks at the pile of bugs we've had to fix in our own application that ended up being because of ruby timezone bullshit*: yea, that makes sense

SportsPuck Appreciation Stel

@darius timezones! Who needs 'em? 🙃

[I don't always test but when I do I test in production.jpg]

Darius Kazemi

Oh well, another day, another data point in favor of "the fact that computers run at all is a miracle"

Darius Kazemi

Wait I stand corrected! There are some tests, they are in Time and not DateTime. But also the ruby docs point out that there are actual differences between the two if you are calculating historical time

github.com/ruby/ruby/blob/d92f

Darius Kazemi

So I guess the most correct thing to say is that there is no test coverage for historical time in Ruby (this matters because time zones change over time so if you are trying to make accurate comparison across years and especially decades this will come into play)

Ryuno-Ki

@darius
Do you have a concrete example that kicked this research of for you?

When you study Ruby's code, perhaps use git blame to check for last change and jump from the commit to a PR to gather more context. Might have a good reason why they didn't invest more effort into this part of the codebase.

Darius Kazemi replied to Ryuno-Ki

@RyunoKi the history of basically all the tests are all clobbered by this commit -- it seems like they haven't really been touched in well over 5 years, I'd have to go back to some previous repository in order to find relevant commits

clarity flowers

@darius @RyunoKi using NodaTime (the library used as a reference in this post) completely changed my perspective on working with datetimes and also now makes me very angry about every language's datetime stdlib which all seemed designed to maximize footguns.

The end result is programmers learn "datetimes are scary" instead of "this stdlib sucks"

kanton bubahsky

@darius so recognisable. i have this weird problem in php where something dated the first of january appears in the _next year. this bug's been around for ages. have to write something myself :(

Go Up