Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

DateTime: 160 Journalism: 0

by mojotoad (Monsignor)
on Apr 28, 2004 at 23:30 UTC ( #348977=CUFP: print w/replies, xml ) Need Help??

I thought I'd share with you a story of DateTime in the trenches. Here in Houston, Texas, in the April 15th issue of our local alternative newspaper the Houston Press they discuss the lyrics of the song "It's Five O'Clock Somewhere" by Jimmy Buffett and Alan Jackson.

In their discussion, they make the following statement:

Pardon us for being nitpicky, but we have some issues with Jimmy Buffett and Alan Jackson's song, "It's Five O'Clock Somewhere." Sure, we get the gist, but the whole concept really belies a complete ignorance of how time zones work. Just in case you haven't heard the song, here's the chorus in question: "Pour me something tall and strong / Make it a hurricane, before I go insane / It's only half past twelve, but I don't care / It's five o'clock somewhere." Apparently Mr. Buffett and Mr. Jackson haven't wandered very far from Margaritaville, 'cause it doesn't take a genius to know that it can't be 5 p.m. anywhere when it's 12:30 p.m. somewhere else.

I knew this couldn't be right since I was aware of at least a couple of time zones with half-hour offsets, plus even one with a 45 minute offset (Nepal). So I whipped up a quick script using DateTime and DateTime::TimeZone, which is based on the Olson Timezone Database, to find out how many time zones for which these requirements might apply. I made a rudimentary attempt at including DST effects by running all calculations twice -- once for Jan 1 and once for Aug 1.

The summary: There are 12 zones, potentially, with half-hour offsets. There are two with 45 minute offsets. There are 160 possible zones for being 5pm when it is 12:30pm somewhere else, out of 367 total.

I've included the script and the letter I sent to the Houston Press. I've no idea if they'll print any of the letter since I didn't get around to checking the facts until recently, but they might.


Update: They published my letter, with minor modifications, in the May 13th, 2004 issue.

Time on My Hands

In the April 15, 2004 "Day by Day" picks Keith Plocek rags on the lyrics for the song "It's Five O'Clock Somewhere" by Jimmy Buffett and Alan Jackson, saying "it doesn't take a genius to know that it can't be 5 p.m. anywhere when it's 12:30 p.m. somewhere else."

Consulting the Olson timezone database, including possible DST effects, it turns out that there are twelve time zones with offsets landing on the half hour. Further calculations relative to those zones reveal 160 candidates out of 367 possible time zones for an offset such as the song suggests.

The next time I'm in Los Angeles in the winter, for example, I can enjoy a 12:30 toast to Jimmy Buffett down in St. Johns where he will no doubt be enjoying his favorite frozen concoction. Jimmy, on the other hand, will have to content himself with a lunchtime toast towards somewhere such as Budapest.

For the record, the twelve zones that enjoy half-hour offsets are: America/St_Johns, Asia/Calcutta, Asia/Kabul, Asia/Rangoon, Asia/Tehran, Australia/Adelaide, Australia/Broken_Hill, Australia/Darwin, Australia/Lord_Howe, Indian/Cocos, Pacific/Marquesas, and Pacific/Norfolk. Things are further complicated by Asia/Katmandu and Pacific/Chatham, which have 45 minute offsets.

Matt Sisk
April 28, 2004

#!/usr/bin/perl # # author: Matt Sisk, April 2004 # no rights reserved -- do what you want with this use strict; use warnings; use DateTime; use DateTime::TimeZone; my %jan_parm = ( year => 2004, month => 1, day => 1); my %aug_parm = ( year => 2004, month => 7, day => 1); my %jan = run_zones(%jan_parm); my %aug = run_zones(%aug_parm); print "Jan (", scalar keys %jan, " zones):\n"; print_zones(\%jan); print "\nAug (", scalar keys %aug, " zones sans jan):\n"; my %notjan; $notjan{$_} = $aug{$_} foreach grep(!$jan{$_}, keys %aug); print_zones(\%notjan); my @znames = DateTime::TimeZone::all_names; my $j5 = find_5_from_12_30(\%jan_parm, [keys %jan], \@znames); my $a5 = find_5_from_12_30(\%aug_parm, [keys %aug], \@znames); my $jj5 = find_5_from_12_30(\%jan_parm, \@znames, [keys %jan]); my $aa5 = find_5_from_12_30(\%aug_parm, \@znames, [keys %aug]); print_one2many($j5, '2004/01/01 12:30 => 17:00'); print_one2many($a5, '2004/07/01 12:30 => 17:00'); print_many2one($jj5, '2004/01/01 12:30 => 17:00'); print_many2one($aa5, '2004/07/01 12:30 => 17:00'); print '-' x 72, "\n"; printf "%3d for %s %5s -> %s\n", scalar keys %$j5, 'Jan', 'other', ' +odd'; printf "%3d for %s %5s -> %s\n", scalar keys %$a5, 'Aug', 'other', ' +odd'; printf "%3d for %s %5s -> %s\n", scalar keys %$jj5, 'Jan', 'odd', ' +other'; printf "%3d for %s %5s -> %s\n", scalar keys %$aa5, 'Aug', 'odd', ' +other'; my %tot; foreach my $h ($j5, $a5, $jj5, $aa5) { foreach (keys %$h) { foreach (keys %{$h->{$_}}) { ++$tot{$_}; } } } print scalar keys %tot, " hits total out of ", scalar @znames, " possibilities.\n"; printf("%.2f%% hit ratio\n", 100*((scalar keys %tot)/(scalar @znames)) +); exit; ### sub run_zones { my %parms = @_; my %zones; foreach my $name (DateTime::TimeZone::all_names) { my $dt = DateTime->new(%parms, time_zone => $name); next unless $dt->offset % 3600; $zones{$name} = $dt->offset; } %zones; } sub find_5_from_12_30 { my($mparms, $basis, $inspects) = @_; my %found; foreach (@$basis) { my $dt = DateTime->new( %$mparms, hour => 12, minute => 30, time_zone => $_, ); find_5_from_dt($dt, $inspects, \%found); } \%found; } sub find_5_from_dt { my($dt, $inspects, $hits) = @_; foreach my $name (@$inspects) { my $c = $dt->clone; $c->set_time_zone($name); if ($c->hour == 17 && $c->minute == 0) { ++$hits->{$dt->time_zone->name}{$name}; } } } sub print_zones { my $h = shift; my $len = 0; foreach (keys %$h) { $len = length if length > $len; } foreach (sort keys %$h) { printf "%${len}s %3d:%02d\n", $_, int($h->{$_}/3600), int(($h->{$_}%3600)/60); } } sub print_many2one { my($h, $label) = @_; print "\n$label\n", '-' x 72, "\n"; my $len = 0; foreach (keys %$h) { $len = length if length > $len; } foreach (sort keys %$h) { printf "%${len}s => %s\n", $_, join(', ', sort keys %{$h->{$_}}); } } sub print_one2many { my($h, $label) = @_; print "\n$label\n", '-' x 72, "\n"; my $len = 0; foreach (keys %$h) { $len = length if length > $len; } foreach (sort keys %$h) { printf("%${len}s =>\n", $_); foreach (sort keys %{$h->{$_}}) { printf "%${len}s %s\n", ' ', $_; } } }
edit (broquaint): added a <readmore>

Replies are listed 'Best First'.
Re: DateTime: 160 Journalism: 0
by flyingmoose (Priest) on Apr 29, 2004 at 18:44 UTC
    The real question is .. given your body weight, temperature, how many cheeseburgers you consumed, whether there was a woman to blame, and various other factors ... how much does it take to get wasted away again in Margarittaville?

    Further: it's not 5 o'clock somewhere on Earth when it is 2:42:05, but if you include the effects of relavitity, it might just be, and that is no excuse to avoid a good beer...Let's all get drunk and code.

Re: DateTime: 160 Journalism: 0
by Errto (Vicar) on Apr 30, 2004 at 02:34 UTC
    Following your link above to the time zone listings at ClariNET, it appears that Mr. Buffett would actually not be very likely to enjoy spending time in St. John's at GMT -0230/0330 as that St. John's is actually in Newfoundland, Canada :)
      Doh! Excellent catch. I just assumed it was St Johns of the Virgin Islands.

      Well, the principle still stands, even if it's not an island paradise.


      However, that puts you plenty close to Halifax, NS, Canada
      which may be {is} one of the best places on earth to drink beer ;-}
      - G -
        I had occasion to test this premise recently, and I have to say I fully concur. Halifax was wonderful -- in addition to the great regional/local beer (which can be found on nearly every corner downtown), the people were absolutely wonderful. There were great maritime/celtic bands, good crowds, etc. I hung out with some of the local artists and we managed to go rockhounding up on the north shore of the Bay of Fundy, which made the whole trip for me. I came back with some nice samples of amythest and agate. On the way back from that expedition we actually stopped at the house of a friend of one of these local artists, someone that was 'into movies', as he put it. This guy had his own boutique vinyard and we sat around his fireplace drinking his homemade muscat wine and talking about politics and philosophy. Great night. As it turns out, this guy was Paul Donovan, one of the writers/producers for the sci-fi series 'Lexx' (of which I was a shameless fan). Small world.


      Actually, Mr. Buffett would have had a great big time on "The Rock". St. John's has George Street which boasts the most bars per capita in the world. As he would be a CFA (Come From Away), they'd have 'Screeched Him In' to make him an honorary Newfie, which includes drinking some very potent rum imported from Jamaica. That sort makes up for having to kiss the cod.

      Anne from Newfoundland (pronounced like 'understand')

        Sounds like a pretty great place as far as I'm concerned. Not too sure about Jimmy Buffett though - he's really more the Caribbean type I think.
Re: DateTime: 160 Journalism: 0
by CloneArmyCommander (Friar) on Apr 29, 2004 at 16:50 UTC
    Hahaha :)! I'll have to keep an eye on the Houston Press and see what kind of argument they put up after you prove them horribly wrong :). I bet they feel stupid after writing that without doing any research :).
Re: DateTime: 160 Journalism: 0
by pileofrogs (Priest) on Mar 15, 2006 at 01:12 UTC

    Here's another take on it:

    Anyone who's ever tried to find their location with a sextant or similar gizmo will tell you it is absolutely 5:00 PM somewhere right now... and also right now.. and also right now..

      True enough.

      But please, could you be more discreet?

      Matt (doing a jig in sidereal time...)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: CUFP [id://348977]
Approved by jdporter
Front-paged by jdporter
[stevieb]: one of my long-running Perl procs crashes with a segfault (because it wraps C code) is crashing after an hour or so... seeing if wrapping the cli call with valgrind will produce something useful

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2017-04-29 03:10 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (531 votes). Check out past polls.