David Pogue has a momentary lapse of judgement when he proclaims in his blog that the date sequence 01:02:03 04/05/06 will only happen once in all of human history.
Besides the obvious gaffes of date formatting (which one is the month and which one is the year?), the red herring of leading zeros (to make the minute and second stand out), and so on, no one who's seen this has made the comment that calendars say whatever we want them to say and the numbers are only special because we set the calendar up that way in this one case. What about the Chinese, Hebrew, and Muslim calendars?
So this seems like a good challenge to publish in The Perl Review: using the Perl Date modules, in how many different calendars and formats can you make this sequence?
I have a few restrictions though: in the chosen calendar, the date and time has to have actually occurred and been observed by society at large (so dates missed by the likes of daylight savings, leap seconds, skipped weeks, and so on don't count). The date format has to be something reasonable and understandable to a majority of people, techies or otherwise (so "YY hh dd ss" sort of formats are out, unless that's how most people format dates for that time (and the US military has a DDHHMMmmmYYYY format, for instance)). The epoch times of 1234567890 won't get points.
I'm especially interested in solutions that will show that a large majority of the population of the planet will live through two such events in their normal lifespan, for instance, once in the normal English date format and once in the Hebrew calendar.
The scoring is up to me and a secret panel of judges, and I'll select valid entries from replies to this post (so offshoot threads in Obfuscated Code, although you have to let me know somehow that their there).
I'll give bonus points to anyone who then gets David Pogue to show their solution (not necessarily the code) as a correction to his post, and double bonus points if he mentions Perl. I'll assign points on code beauty, cleverness, and understandability, with maybe a special category for obfuscation.
That must be worth at least a free copy of Learning Perl and Intermediate Perl, and some free subscriptions to The Perl Review (to anywhere in the world the US Post Office will send things). The number of prizes will not be less than three, but are maximally unbound.
Assuming good fortune, won't Hideko Arima and Ivy Smith both have experienced that date (at least) twice in their lifetimes, a month from now?
I'm especially interested in solutions that will show that a large majority of the population of the planet will live through two such events in their normal lifespanWell, without writing any code at all, I know of two that have already occurred during my lifespan.
Cheers,
Darren :)
First there's Swatch time (Beat Time) which gives 1000 beats to each day. See [cpan://Time::Beat] or [cpan://DateTime::Format::IBeat]. IBeat has a way to parse dates as well, so one of these must be right. The answer to the last one is something between @084 and @085.
@d01.02.03 @456 Beat Time is 2003-02-01T09:56:38 Gregorian. @d04.05.06 @123 Beat Time is 2006-05-04T01:57:07 Gregorian. @d04.05.06 @085 Beat Time is 2006-05-04T01:02:24 Gregorian.
The key is to know that in Japan, many people will now read it as a date 12 years ago and not 2006 (which is Heisei 18). People usually write out 2006 I think, whereas the year 6 would be "Heisei 6" (6th year of the reign of the Heisei Emperor). I will not cause bad luck and tell you how someone born 12 years ago can experience that date three times. But I can say that lots of Japanese have experienced the date already three times, thanks to the "greying of Japan". The previous emperor was Emperor Showa, whose reign began in 1925. So Showa 6 was 1931. So anybody over 75 years old (and there are a *lot* of them here) lived through both Showa 6 and Heisei 6, plus 2006 of course. I tried the modern Japanese calendar module but had trouble pasting the Japanese output from a non-Japanese terminal session (maybe it can be done but..) So, Tatsuhiko Miyagawa's [cpan://Date::Japanese::Era] to the rescue.
use Date::Japanese::Era;
my $era = Date::Japanese::Era->new(2006, 4, 5);
print "2006 is " . uc($era->name_ascii) . " " . $era->year . "\n";
for my $Emperor (qw(heisei taishou meiji)) {
$era = Date::Japanese::Era->new($Emperor, 6);
print uc($Emperor) . " 6 is " . $era->gregorian_year . "\n";
}
2006 is HEISEI 18
HEISEI 6 is 1994
TAISHOU 6 is 1917
MEIJI 6 is 1873
use Locale::Hebrew::Calendar;
my ($dd,$mm,$yy) = ("04","05","-1806");
# Gregorian to Jewish
my ($d, $m, $y) = Locale::Hebrew::Calendar::g2j($dd, $mm, $yy);
print "G2J: $d/$m/$y\n";
$perl hebrewcal.pl
G2J: 11/7/1954
If this meets your approval I'd like Damian's Practices or MJD's new book instead! :)
"the date sequence 01:02:03 04/05/06 will only happen once in all of human history"
As the OP stresses, the Gregorian calendar is by no means the only one in existence. However, before looking at other calendars, let's see all the ways Mr Pogue got it wrong just within his own frame of reference.
As already pointed out, even assuming HH:MM:SS MM/DD/YY, this sequence will, of course, occur every century in human history.
1.1.2.1 Preliminary remarks: Let us accept the convention, for the sake of argument, that a slash ('/') separates years from months from days (in whatever order, see below) and that a colon (':') separates hours from minutes from seconds (again in whatever order). This precludes, for example, interpreting our sequence as 'Jan 2 2003 at 4h:5m:6s', or McDarren's creative suggestions above. Let us also assume a 24 hour clock.
1.1.2.2 MM/DD/YY: This is just one ordering convention*. What about DD/MM/YY (Widely used in Europe)? Or YY/MM/DD? There are in fact six possible ways of ordering these elements, which means that '04/05/06' occurs 6 times every century.
* Used mainly, I believe, in North America.1.1.2.3 HH:MM:SS: In theory, there are also six ways of interpreting this part of our sequence. However, I can find no evidence advocating anything other than descending (HH:MM:SS) or ascending (SS:MM:HH) order. This still means that we must double the number of times that our sequence may happen each century.
1.1.2.4 Conclusion: $NUMBER_OF_TIMES_PER_CENTURY = 12.
Sentences along the lines of "Emperor Foo was crowned on 5 April 405 BC(E)" are common in texts about ancient history. As none of the numbers in our sequence are signed, we may interpret this date (assuming MM/DD/YY format) as matching '04/05/06'*.
* If you are unconvinced by this reasoning, just replace the value of the constant $BEGINNING_OF_HUMAN_HISTORY by 1**. Note, however, that you will have to adjust for all the other (non-Gregorian, see below) calendars accordingly.I am no calendar expert, but basic googling suggests that the number of known calendars (in common use now or in the past) is at least in the hundreds*. Arbitrarily, I set the value of $NUMBER_OF_CALENDARS at 300. Feel free to adjust this value as you please.
* Of course, not all of these calendars are based on a 'year' of 365-and-a-bit days, or a 'month' of 30-odd days, not to mention the division of a day into 24 'hours', 60 'minutes' and 60 'seconds'). Adjusting the code for this factor is left as an exercise for the reader.It might be argued that the date 04/07/2006 (today, in Gregorian MM/DD/YYYY format) didn't exist in, for example, the French Revolutionary calendar, which was abolished, if I remember well, in 1806, having lasted for less than 13 years*. However, it was perfectly possible to express future dates in this calendar (today, for example, would be 'Décade II, Octidi de Germinal de l'Année CCXIV de la Revolution', or, in MM/DD/YY format, 02/07/04)**, just as we can quite validly write 03/03/2525 (in Gregorian) today, despite the fact that the world might be invaded by Klingons tomorrow, and that they could impose their own calendar, rendering all our existing ones obsolete. Similarly, there is no problem in expressing a date in the arbitrarily distant past in either of the example calendars under discussion. From this we may conclude that any calendar is capable of expressing any date in history.
* Ignoring a brief attempt to re-introduce it during the Paris Commune some 65 years later.Once again for the sake of argument, let us define the beginning of humanity with the emergence of Homo sapiens (rather than, for example, H. neanderthalensis or H. erectus). I am no more a palaeoanthropologist than I am a calendar expert, but according to Wikipedia, "H. sapiens has lived from around 200 TYA (Thousand Years Ago) to the present". On this basis, we may set the value of $BEGINNING_OF_HUMAN_HISTORY at 197994 (200,000 2006).*
* You may wish to change this value as new fossil discoveries are made (or, of course, in function of your particular religious beliefs).I personally am sceptical as to mankind's chances of surviving the 21st Century, given the way we're treating our planet. However, this is no place for a diatribe about global warming and the like. Looking on the bright side, Id give us another couple of millennia before we become extinct. On this basis, I set the constant $END_OF_HUMAN_HISTORY at 4006 (YMMV).
So, given the above, here's my code:
use strict;
use warnings;
my $NUMBER_OF_TIMES_PER_CENTURY = 12;
my $NUMBER_OF_CALENDARS = 300;
my $BEGINNING_OF_HUMAN_HISTORY = 197994;
my $END_OF_HUMAN_HISTORY = 4006;
my $human_history = $BEGINNING_OF_HUMAN_HISTORY + $END_OF_HUMAN_HISTORY;
my $centuries = $human_history / 100;
my $total = $centuries * $NUMBER_OF_TIMES_PER_CENTURY * $NUMBER_OF_CALENDARS;
if ( $total > 1 ) {
print "David Pogue was wrong\n";
}
perlmonks.org content © perlmonks.org and brian_d_foy, BrowserUk, cyclist38, jcoxen, lidden, mattr, McDarren, Not_a_Number
prlmnks.org © 2006 edmund von der burg (eccles & toad)
v 0.03