So, I’m working on a little side project. This side project is a website / mobile website that has to care about time. So, a human being wants to set a time and a place, for example, “The movie theatre at address X at 9:00 pm”.
Well, the fact of the matter is that 9:00 pm is a lie. There is no such thing as 9:00 pm. There is 9:00 pm in a certain time zone on a certain date. So, I was at a hackaton, worrying about how to implement this properly. You see, it’s possible that a person would have multiple locations within a block. It’s possible even that within a block, one of those location/time tuples may be in a different time zone than the next location/time tuple. It’s also possible that the person *entering* the time is themselves in a different time zone than the person who is supposed to fulfill the location/time tuples intent. It’s also possible that the server who fulfills the location/time tuple action is in a totally different timezone. And it’s further possible that the very next location/time tuple action is handled by a totally different server in a totally different timezone.
Real software problems. Hard software problems. Time is a challenging abstraction, and handling time properly is hard. Handling time properly with an understanding of timezone spanning and 3rd party oberservers of time, is even harder. So, I reach for CPAN and start assembling the modules I need to do things properly.
I bust out Time::Piece, DateTime, DBIx::Class::InflateColumn::DateTime, Date::Parse, and one or two other ones I’m thinking about. I step outside to talk clear my mind, and start talking to another hackathon participant. He asks me, “so what are you coding in?” and I tell him Perl. He mentions that I must be very old, it hurts my feelings. I invest about 45 seconds to let him know that Perl has experienced one heck of a renaissance! But they weren’t even listening, and I wasn’t in the mood to waste my breath. He proceeds to tell me that I’m wasting my time, and that I should really be programming in Ruby.
“You see, there’s this thing called gems, man. And everyone is putting their code in these gems, and it’s incredible. You don’t have to do any of that shit any more. Perl is too low level, I can’t solve any real problems in it.” He said. Young. So young. More importantly, clearly someone who hasn’t actually developed software that has to run 24/7. Software that if it fails, someone may lose an arm. The kind of software that powers multi-million dollar enterprises. Not to say that people using his stack *couldn’t* do so… but this young kid clearly hadn’t done it.
So I ask him: “ok, so I have to track multiple sets of time/location tuples in a way which is completely timezone agnostic, messaging needs to happen to people in those timezones in real time, an external person in a different timezone may require completely different messages at different times but calculated off of offsets of of their timezones, it’s possible that these sets themselves span multiple timezones, and it’s further possible that the servers are themselves in multiple different timezones. How would you solve it?”
I expected him to tell me an answer that made sense, something like: “don’t store timezones, convert everything to UTC and make your tuple consumer logic do timezone transformations in real time” or something even more clever than I could have come up with. I waited, and took a deep breath of the crisp fresh air.
He replied: “Perl is just too low level. I’d find a ruby gem that handled that.”
Thanks kid, I appreciate it.
UPDATE: If there is a ruby gem that handles this, I’d love to hear about it.