brian_d_foy has asked for the wisdom of the Perl Monks concerning the following question:

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 (or not, I guess), in how many different calendars and formats can you make this sequence? What else is special about those days (are they a weekend, fall on a full moon, have a solar eclipse, etc.)?

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.

--
brian d foy <brian@stonehenge.com>
Subscribe to The Perl Review
  • Comment on The Perl Review's Date Format Challenge

Replies are listed 'Best First'.
Re: The Perl Review's Date Format Challenge
by McDarren (Abbot) on Apr 05, 2006 at 00:10 UTC
    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
    Well, without writing any code at all, I know of two that have already occurred during my lifespan.
    • 1:23:45 6/7/89 (h:mm:ss d/m/yy), and
    • 12:34:56 7/8/90 (hh:mm:ss d/m/yy)
    Both of those are in "English" date format (I believe that m/d/y is "American" date format). Although, they are valid dates in either format, I guess.

    Cheers,
    Darren :)

Re: The Perl Review's Date Format Challenge
by lidden (Curate) on Apr 05, 2006 at 02:34 UTC
    the date sequence 01:02:03 04/05/06 will only happen once in all of human history.

    That sequence uses two digits for the year and will happen every 100 years.
      Assuming a 12 hour clock, it'll happen twice today - 01:02:03 04/05/06 A.M. and 01:02:03 04/05/06 P.M.

      Jack

Re: The Perl Review's Date Format Challenge
by cyclist38 (Hermit) on Apr 05, 2006 at 00:06 UTC
    I think the easiest and most obvious is 01 02 03 04 05 06 (01:02:03 4 may 2006) on the European calendar.
Re: The Perl Review's Date Format Challenge
by BrowserUk (Patriarch) on Apr 05, 2006 at 00:05 UTC

    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?


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re: The Perl Review's Date Format Challenge
by mattr (Curate) on Apr 05, 2006 at 16:08 UTC
    Looks like jcoxen already got it but here's my shot at it.

    First there's Swatch time (Beat Time) which gives 1000 beats to each day. See Time::Beat or DateTime::Format::IBeat. IBeat has a way to parse dates as well, so one of these must be right.

    @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 answer to the last one is something between @084 and @085. So depending on your opinion, using the Beat calendar gives us alternate dates of Feb. 1, 2003 and May 4, 2006. Well, this seems to depend either on a European vs. American ordering of month and day, or on Swatch's choice of writing the date before the time.

    But as long as you realize it is the same Swatch (Beat) time all over the world at a given instant, you can rest assured there will be a lot of people who refuse to accept whichever ordering is being used at any given time. Erm. Well, on to the next.

    I tried Audrey Tang's Locale::Hebrew::Calendar but of course the year is off by thousands, not useful for duplicating a date in a single lifetime.. or is it? (Stay tuned!)

    On to some interesting modules by Daisuke Maki, who did DateTime::Calendar::Japanese which is a a 19th century calendar. (DateTime::Format::Japanese is the modern one).

    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 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

    Back to Audrey's Locale::Hebrew::Calendar which proved bendable, regardless of the 5000+ year difference in dates!
    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

    So I finally found a good use for Y2K after all. Realizing that Y2K also means Y3K ad infinitum, all people living in the past present and future can indeed experience 04.05.06 twice.

    If this meets your approval I'd like Damian's Practices or MJD's new book instead! :)

Re: The Perl Review's Date Format Challenge
by Not_a_Number (Prior) on Apr 07, 2006 at 18:44 UTC
    "the date sequence 01:02:03 04/05/06 will only happen once in all of human history"

    1 Calendar considerations

    1.1 The Gregorian calendar

    As the OP stresses, the Gregorian calendar is by no means the only one in existence. However, before looking at other calendars, let's examine all the ways Mr Pogue got it wrong just within his own frame of reference.

    1.1.1 Basic silliness

    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 Ordering conventions

    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.

    1.1.3 BCE vs CE (BC vs AD)

    Sentences along the lines of "Emperor Foo was crowned on 5 April 406 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.
    ** Remember that there was no year 0 (although that doesn’t really matter in this particular case).

    1.2 Other calendars

    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.

    1.3 'Scope' of a given calendar

    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 my memory serves me 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/14)**, just as we can quite validly write 03/03/2525 (in Gregorian) today, despite the fact that the Earth 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 (past, present or future).

    * Ignoring a brief attempt to re-introduce it during the Paris Commune some 65 years later.
    ** My calculations might be wrong, but you will agree that this doesn't affect the thrust of my argument :).

    2 Human history

    2.1 Beginning of human history

    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* to the present". On this basis, we may set the value of $BEGINNING_OF_HUMAN_HISTORY at 197994 (200,000 – 2006).**

    * Thousand Years Ago.
    ** You may wish to change this value as new fossil discoveries are made (or, of course, in function of your particular religious beliefs).

    2.2 End of human history

    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, why not 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 (untested):

    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_HISTOR +Y; my $centuries = $human_history / 100; my $total = $centuries * $NUMBER_OF_TIMES_PER_CENTURY * $NUMBER_OF_CAL +ENDARS; if ( $total > 1 ) { print "David Pogue was wrong\n"; }

    Update: Corrected a couple of silly mistakes.