Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: The Perl Review's Date Format Challenge

by mattr (Curate)
on Apr 05, 2006 at 16:08 UTC ( [id://541422]=note: print w/replies, xml ) Need Help??


in reply to The Perl Review's Date Format Challenge

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! :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://541422]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-03-29 07:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found