Rose-DateTime-0.540/000750 000765 000120 00000000000 12251103544 014177 5ustar00johnadmin000000 000000 Rose-DateTime-0.540/Changes000755 000765 000120 00000007557 12251103520 015512 0ustar00johnadmin000000 000000 0.540 (12.08.2013) - John Siracusa * Handle object return value from DateTime->DefaultLocale. 0.539 (10.03.2013) - John Siracusa * Fixed a typo in the documentation. (RT 89224) 0.538 (03.20.2013) - John Siracusa * Ensure that "today" is parsed as a DateTime with the time set to 00:00:00. (RT 84068) 0.537 (05.04.2011) - John Siracusa * Well that was fast. DateTime 0.69 fixes RT 67928. Tests updated. 0.536 (05.03.2011) - John Siracusa * Account for changes in DateTime 0.67 and later and work around http://rt.cpan.org/Public/Bug/Display.html?id=67928 0.535 (01.24.2010) - John Siracusa * Handle pre-0.4 version of DateTime::Locale. (RT 65070) 0.534 (03.22.2010) - John Siracusa * Updated to avoid calling methods that were deprecated in DateTime::Locale version 0.44 and later. 0.533 (10.16.2009) - John Siracusa * Updated eval blocks to avoid stomping on $@ from an outer scope. 0.532 (10.23.2006) - John Siracusa * Made compatible with DateTime 0.35 and DateTime::Locale 0.31. (Patch by Lucian Dragus) 0.531 (10.06.2006) - John Siracusa * parse_date() now accepts "now!" as an alias for "now". * Fixed a typo in the documentation. 0.53 (06.07.2006) - John Siracusa * parse_date() now accepts epoch values in the full range, not just 9 or 10 digit numbers. * Added parse_epoch() function to resolve the now-ambiguous parse_date() behavior with respect to epochs and YYYYMMDD values. 0.522 (04.08.2006) - John Siracusa * Updated the test suite to account for systems that can't handle negative epoch values. (Thanks to Michael Lackhoff) 0.521 (04.05.2006) - John Siracusa * Removed stray "._*" files from module distribution. 0.52 (04.04.2006) - John Siracusa * Allow negative and fractional epoch values in parse_date(). * Fixed a bug in the yyyy-mm-dd date parsing that caused it to incorrectly match 10-digit seconds-since-epoch values. (Reported by Peter Karman) 0.51 (03.16.2006) - John Siracusa * The european_dates() setting is now initialized as appropriate for the current locale, discovered via to DateTime->DefaultLocale(). (Suggested by Michael Lackhoff) 0.50 (03.07.2006) - John Siracusa * Added support for Euorpean-style (dd/mm/yyyy) dates. * Big version number bump to reflect progress towards 1.0. 0.0134 (08.22.2005) - John Siracusa * Fixed incorrect version number in one file. 0.0133 (08.20.2005) - John Siracusa * POD fixes. 0.0131 (03.10.2005) - John Siracusa * Fixed POD errors in Rose::DateTime::Util. 0.013 (02.26.2005) - John Siracusa * Changed default time zone from 'local' to 'floating' in Rose::DateTime::Util in order to avoid unnecessary overhead when setting the time zone explicitly. 0.0122 (12.14.2004) - John Siracusa * Ho hum, another day, another release. Documentation patch again to fix more typos and further clarify local time zone shenanigans. 0.0121 (12.13.2004) - John Siracusa * Documentation patch to fix typos and clarify local time zone shenanigans. 0.012 (12.08.2004) - John Siracusa * Fix attempt to fail gracefully when the local time zone cannot be determined. 0.011 (11.14.2004) - John Siracusa * Added copyright info. Version 0.01 removed. 0.01 (11.13.2004) - John Siracusa * Initial release. Rose-DateTime-0.540/lib/000750 000765 000120 00000000000 12251103544 014745 5ustar00johnadmin000000 000000 Rose-DateTime-0.540/Makefile.PL000755 000765 000120 00000000664 10760063453 016176 0ustar00johnadmin000000 000000 require 5.006; use ExtUtils::MakeMaker; WriteMakefile(NAME => 'Rose::DateTime', PMLIBDIRS => [ 'lib' ], VERSION_FROM => 'lib/Rose/DateTime.pm', ($^O =~ /darwin/i ? (dist => { DIST_CP => 'cp' }) : ()), # Avoid Mac OS X ._* files PREREQ_PM => { 'DateTime' => 0, 'Rose::Object' => 0.82, }); Rose-DateTime-0.540/MANIFEST000755 000765 000120 00000000470 12251103544 015341 0ustar00johnadmin000000 000000 Changes lib/Rose/DateTime.pm lib/Rose/DateTime/Parser.pm lib/Rose/DateTime/Util.pm Makefile.PL MANIFEST t/basic.t t/locale.t t/parser.t t/pod.t META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) Rose-DateTime-0.540/META.json000660 000765 000120 00000001544 12251103544 015627 0ustar00johnadmin000000 000000 { "abstract" : "unknown", "author" : [ "unknown" ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 6.64, CPAN::Meta::Converter version 2.120921", "license" : [ "unknown" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Rose-DateTime", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "DateTime" : "0", "Rose::Object" : "0.82" } } }, "release_status" : "stable", "version" : "0.540" } Rose-DateTime-0.540/META.yml000660 000765 000120 00000000716 12251103544 015457 0ustar00johnadmin000000 000000 --- abstract: unknown author: - unknown build_requires: ExtUtils::MakeMaker: 0 configure_requires: ExtUtils::MakeMaker: 0 dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 6.64, CPAN::Meta::Converter version 2.120921' license: unknown meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Rose-DateTime no_index: directory: - t - inc requires: DateTime: 0 Rose::Object: 0.82 version: 0.540 Rose-DateTime-0.540/t/000750 000765 000120 00000000000 12251103544 014442 5ustar00johnadmin000000 000000 Rose-DateTime-0.540/t/basic.t000755 000765 000120 00000034523 12125305774 015740 0ustar00johnadmin000000 000000 #!/usr/bin/perl -w use strict; use Test::More tests => 5531; BEGIN { use_ok('Rose::DateTime::Util'); use_ok('DateTime'); } use Rose::DateTime::Util qw(:all); # test import # Test to see if we can creat local DateTimes eval { DateTime->now(time_zone => 'local') }; # Use UTC if we can't Rose::DateTime::Util->time_zone('UTC') if($@); # # parse_date() # my $dt1 = DateTime->new(month => 2, day => 3, year => 2004, hour => 13, minute => 34, second => 56, time_zone => Rose::DateTime::Util->time_zone); my $dt2 = DateTime->new(month => 2, day => 3, year => 2004, hour => 13, minute => 34, second => 56, nanosecond => '123456789', time_zone => Rose::DateTime::Util->time_zone); my $dt3 = DateTime->new(month => 2, day => 3, year => 2004, hour => 13, minute => 34, second => 56, nanosecond => '1234', time_zone => Rose::DateTime::Util->time_zone); my $dt4 = DateTime->new(month => 2, day => 3, year => 2004, hour => 13, minute => 34, second => 56, nanosecond => '123400000', time_zone => Rose::DateTime::Util->time_zone); Rose::DateTime::Util->european_dates(0); # mm/dd/yyyy [hh:mm[:ss[.nnnnnnnnn]]] [am/pm] foreach my $month (qw(2 02)) { foreach my $day (qw(3 03)) { foreach my $hour (qw(1 01)) { foreach my $fsec ('', '.', '.0', '.123456789') { foreach my $sep ('-', '/', '.') { foreach my $sep3 ('', ' ') { foreach my $pm ('Pm', 'p.M.') { my $arg = "$month$sep$day${sep}2004 $hour:34:56$fsec$sep3$pm"; my $d = parse_date($arg); ok($d && $d->isa('DateTime'), "$arg"); SKIP: { skip("Failed to parse '$arg'", 1) unless($d); if(index($fsec, '9') > 0) { ok($d == $dt2, "$arg 2"); } #elsif($fsec =~ /4$/) #{ # ok($d == $dt3, "$arg 2"); #} #elsif($fsec =~ /4$/) #{ # ok($d == $dt3, "$arg 2"); #} else { ok($d == $dt1, "$arg 2"); } } $arg = "$month$sep$day${sep}2004 13:34:56$fsec"; $d = Rose::DateTime::Util::parse_date($arg); ok($d && $d->isa('DateTime'), "$arg"); SKIP: { skip("Failed to parse '$arg'", 1) unless($d); if(index($fsec, '9') > 0) { ok($d == $dt2, "$arg 2"); } #elsif($fsec =~ /4$/) #{ # ok($d == $dt3, "$arg 2"); #} #elsif($fsec =~ /4$/) #{ # ok($d == $dt3, "$arg 2"); #} else { ok($d == $dt1, "$arg 2"); } } } } } } } } } # dd/mm/yyyy [hh:mm[:ss[.nnnnnnnnn]]] [am/pm] foreach my $month (qw(2 02)) { foreach my $day (qw(3 03)) { foreach my $hour (qw(1 01)) { foreach my $fsec ('', '.', '.0', '.123456789') { foreach my $sep ('-', '/', '.') { foreach my $sep3 ('', ' ') { foreach my $pm ('Pm', 'p.M.') { my $arg = "$day$sep$month${sep}2004 $hour:34:56$fsec$sep3$pm"; my $d = parse_european_date($arg); ok($d && $d->isa('DateTime'), "$arg"); SKIP: { skip("Failed to parse '$arg'", 1) unless($d); if(index($fsec, '9') > 0) { ok($d == $dt2, "$arg 2"); } else { ok($d == $dt1, "$arg 2"); } } $arg = "$day$sep$month${sep}2004 13:34:56$fsec"; $d = Rose::DateTime::Util::parse_european_date($arg); ok($d && $d->isa('DateTime'), "$arg"); SKIP: { skip("Failed to parse '$arg'", 1) unless($d); if(index($fsec, '9') > 0) { ok($d == $dt2, "$arg 2"); } else { ok($d == $dt1, "$arg 2"); } } } } } } } } } # dd/mm/yyyy [hh:mm[:ss[.nnnnnnnnn]]] [am/pm] (implicit European mode) is(Rose::DateTime::Util->european_dates, 0, 'european_dates() 1'); is(Rose::DateTime::Util->european_dates('foo'), 1, 'european_dates() 2'); foreach my $month (qw(2 02)) { foreach my $day (qw(3 03)) { foreach my $hour (qw(1 01)) { foreach my $fsec ('', '.', '.0', '.123456789') { foreach my $sep ('-', '/', '.') { foreach my $sep3 ('', ' ') { foreach my $pm ('Pm', 'p.M.') { my $arg = "$day$sep$month${sep}2004 $hour:34:56$fsec$sep3$pm"; my $d = Rose::DateTime::Util::parse_date($arg); ok($d && $d->isa('DateTime'), "$arg"); SKIP: { skip("Failed to parse '$arg'", 1) unless($d); if(index($fsec, '9') > 0) { ok($d == $dt2, "$arg 2"); } else { ok($d == $dt1, "$arg 2"); } } $arg = "$day$sep$month${sep}2004 13:34:56$fsec"; $d = Rose::DateTime::Util::parse_date($arg); ok($d && $d->isa('DateTime'), "$arg"); SKIP: { skip("Failed to parse '$arg'", 1) unless($d); if(index($fsec, '9') > 0) { ok($d == $dt2, "$arg 2"); } else { ok($d == $dt1, "$arg 2"); } } } } } } } } } is(Rose::DateTime::Util->european_dates(''), 0, 'european_dates() 3'); # yyyy-mm-dd [hh:mm[:ss[.nnnnnnnnn]]] [am/pm] foreach my $hour (qw(1 01)) { foreach my $fsec ('', '.', '.0', '.123456789') { foreach my $sep ('-', '') { foreach my $sep3 ('', ' ') { foreach my $pm ('Pm', 'p.M.') { foreach my $sep4 ('', ' ', '-') { my $arg = "2004${sep}02${sep}03${sep4}$hour:34:56$fsec$sep3$pm"; my $d = Rose::DateTime::Util::parse_date($arg); ok($d && $d->isa('DateTime'), "$arg"); SKIP: { skip("Failed to parse '$arg'", 1) unless($d); if(index($fsec, '9') > 0) { ok($d == $dt2, "$arg 2"); } #elsif($fsec =~ /4$/) #{ # ok($d == $dt3, "$arg 2"); #} #elsif($fsec =~ /4/) #{ # ok($d == $dt3, "$arg 2"); #} else { ok($d == $dt1, "$arg 2"); } } $arg = "2004${sep}02${sep}03${sep4}13:34:56$fsec"; $d = Rose::DateTime::Util::parse_date($arg); ok($d && $d->isa('DateTime'), "$arg"); SKIP: { skip("Failed to parse '$arg'", 1) unless($d); if(index($fsec, '9') > 0) { ok($d == $dt2, "$arg 2"); } #elsif($fsec =~ /4$/) #{ # ok($d == $dt3, "$arg 2"); #} #elsif($fsec =~ /4/) #{ # ok($d == $dt4, "$arg 2"); #} else { ok($d == $dt1, "$arg 2"); } } } } } } } } my $d = parse_date('1/2/2003 8am'); my $d2 = parse_date('1/2/2003 8:00:00.000000000 AM'); ok($d == $d2, 'parse_date(m/d/yyyy ham)'); $d2 = parse_date('2003-01-02 8:00:00.000000000 AM'); ok($d == $d2, 'parse_date(m/d/yyyy ham) 2'); my $now = parse_date('now'); my $dt_now = DateTime->now->truncate(to => 'minute'); ok($now && $now->isa('DateTime'), 'now'); # Time marches on; did we cross minute? if($now) { $now->truncate(to => 'minute'); $now = parse_date('now')->truncate(to => 'minute') unless ($now == $dt_now); } is($now, $dt_now, 'now is current'); my $today = parse_date('today'); my $dt_today = DateTime->now->truncate(to => 'day'); ok($today && $today->isa('DateTime'), 'today'); # Similarly for midnight if($today and $today != $dt_today) { $today = parse_date('today'); } is($today, $dt_today, 'today is current'); my $inf = parse_date('infinity'); my $ninf = parse_date('-infinity'); is(format_date($inf), 'infinity', 'format infinity'); is(format_date($ninf), '-infinity', 'format -infinity'); my $arg = '1/2/2003 12:34:56.001'; $d = parse_date($arg); ok($d && $d->isa('DateTime'), $arg); is($d->nanosecond, '001000000', 'Nanoseconds 1'); $arg = '1/2/2003 12:34:56.100'; $d = parse_date($arg); ok($d && $d->isa('DateTime'), $arg); is($d->nanosecond, 100000000, 'Nanoseconds 2'); $d = parse_date($arg, 'floating'); ok($d && $d->isa('DateTime'), $arg); is($d->time_zone->name, 'floating', 'parse_date() time zone floating'); $d = parse_date($arg, 'UTC'); ok($d && $d->isa('DateTime'), $arg); is($d->time_zone->name, 'UTC', 'parse_date() time zone UTC'); $d2 = parse_date($d); ok($d2 && $d2->isa('DateTime') && $d2 eq $d, 'parse_date(DateTime)'); $d2 = parse_date($d, 'floating'); ok($d2 && $d2->isa('DateTime') && $d2->time_zone->name eq 'floating', 'parse_date(DateTime, TZ) 2'); $d2 = parse_date('.'); ok(!defined $d2, 'parse_date(.)'); $d2 = parse_date('.123'); is($d2->strftime('%Y-%m-%d %H:%M:%S.%N'), '1970-01-01 00:00:00.123000000', 'parse_date(.123)'); $d2 = parse_date('1.123'); is($d2->strftime('%Y-%m-%d %H:%M:%S.%N'), '1970-01-01 00:00:01.123000000', 'parse_date(1.123)'); $d2 = parse_date('19991201'); is($d2->strftime('%Y-%m-%d'), '1999-12-01', 'parse_date(19991201)'); $d2 = parse_epoch('19991201'); is($d2->strftime('%Y-%m-%d'), '1970-08-20', 'parse_date(parse_epoch)'); $d2 = parse_date($d, 'nonesuchasdf'); ok(!defined $d2, 'parse_date(DateTime, invalid TZ)'); # # error() # ok(Rose::DateTime::Util->error =~ /\S/, 'error()'); # # format_date() # foreach my $fmt (qw(a A b B c C d D e G g h H I j k l m M n N p P r R s S T u U V w W x X y Y z Z %)) { is(format_date($d, '%' . $fmt), $d->strftime('%' . $fmt), "format_date(%$fmt)"); } my @s = format_date($d, '%m', '%d', '%Y'); is($s[0], '01', 'format_date() list context 1'); is($s[1], '02', 'format_date() list context 2'); is($s[2], '2003', 'format_date() list context 3'); foreach my $p ('', 2) { $arg = "12/${p}1/1984"; $d = parse_date($arg); ok($d && $d->isa('DateTime'), $arg); is(format_date($d, '%E'), "${p}1st", "format_date(%E) ${p}1st"); $arg = "12/${p}2/1984"; $d = parse_date($arg); ok($d && $d->isa('DateTime'), $arg); is(format_date($d, '%E'), "${p}2nd", "format_date(%E) ${p}2nd"); $arg = "12/${p}3/1984"; $d = parse_date($arg); ok($d && $d->isa('DateTime'), $arg); is(format_date($d, '%E'), "${p}3rd", "format_date(%E) ${p}3rd"); } foreach my $day (4 .. 20, 24 .. 30) { $arg = "12/$day/1984"; $d = parse_date($arg); ok($d && $d->isa('DateTime'), $arg); is(format_date($d, '%E'), $day . 'th', 'format_date(%E) ' . $day . 'th'); } $arg = '12/31/1984'; $d = parse_date($arg); ok($d && $d->isa('DateTime'), $arg); is(format_date($d, '%E'), '31st', 'format_date(%E) ' . '31st'); # # time_zone() # Rose::DateTime::Util->time_zone('floating'); $arg = '12/31/1984'; $d = parse_date($arg); ok($d && $d->isa('DateTime'), $arg); is($d->time_zone->name, 'floating', 'time_zone() floating'); Rose::DateTime::Util->time_zone('UTC'); $d = parse_date($arg); ok($d && $d->isa('DateTime'), $arg); is($d->time_zone->name, 'UTC', 'time_zone() UTC'); is(Rose::DateTime::Util->time_zone, 'UTC', 'time_zone() get'); # # Epoch vs. yyyymmdd hh # $d = parse_date(1143744435); is($d->strftime('%Y-%m-%d %H:%M:%S'), '2006-03-30 18:47:15', 'Epoch vs. yyyymmdd 1'); $d = parse_date('1143744435.123456789'); is($d->strftime('%Y-%m-%d %H:%M:%S.%N'), '2006-03-30 18:47:15.123456789', 'Epoch vs. yyyymmdd 2'); # Check copied from DateTime's 04epoch.t test my $negative_epoch_ok = defined((localtime(-1))[0]) ? 1 : 0; if($negative_epoch_ok) { $d = parse_date('-1143744435.123456789'); is($d->strftime('%Y-%m-%d %H:%M:%S.%N'), '1933-10-04 05:12:45.123456789', 'Epoch vs. yyyymmdd 3'); } else { ok(1, "This system ($^O) can't handle negative epoch values"); } $d = parse_date('1143744435.123451234'); is($d->strftime('%Y-%m-%d %H:%M:%S.%5N'), '2006-03-30 18:47:15.12345', 'Epoch vs. yyyymmdd 4'); $d = parse_date('1143744435.123'); is($d->strftime('%Y-%m-%d %H:%M:%S.%5N'), '2006-03-30 18:47:15.12300', 'Epoch vs. yyyymmdd 5'); $d = parse_date('1143744435.'); if ($DateTime::VERSION >= 0.67 && $DateTime::VERSION <= 0.68) { is($d->strftime('%Y-%m-%d %H:%M:%S.%5N'), '2006-03-30 18:47:15.0', 'Epoch vs. yyyymmdd 6'); } else { is($d->strftime('%Y-%m-%d %H:%M:%S.%5N'), '2006-03-30 18:47:15.00000', 'Epoch vs. yyyymmdd 6'); } $d = parse_date('19800102 8pm'); is($d->strftime('%Y-%m-%d %H:%M:%S'), '1980-01-02 20:00:00', 'yyyymmdd 1'); $d = parse_date('198001028pm'); is($d->strftime('%Y-%m-%d %H:%M:%S'), '1980-01-02 20:00:00', 'yyyymmdd 2'); $d = parse_date('19800102T8pm'); is($d->strftime('%Y-%m-%d %H:%M:%S'), '1980-01-02 20:00:00', 'yyyymmdd 4'); $d = parse_date('19800102_8pm'); is($d->strftime('%Y-%m-%d %H:%M:%S'), '1980-01-02 20:00:00', 'yyyymmdd 5'); $d = parse_date('19800102-8pm'); is($d->strftime('%Y-%m-%d %H:%M:%S'), '1980-01-02 20:00:00', 'yyyymmdd 6'); $d = parse_date('1980.01.02.8:00'); is($d->strftime('%Y-%m-%d %H:%M:%S'), '1980-01-02 08:00:00', 'yyyymmdd 7'); $d = parse_date('1980_01_02T8:00'); is($d->strftime('%Y-%m-%d %H:%M:%S'), '1980-01-02 08:00:00', 'yyyymmdd 8'); $d = parse_date('1980_01.02-8:00'); is($d->strftime('%Y-%m-%d %H:%M:%S'), '1980-01-02 08:00:00', 'yyyymmdd 9'); $d = parse_date('01.02_1980-8'); is($d->strftime('%Y-%m-%d %H:%M:%S'), '1980-01-02 08:00:00', 'yyyymmdd 10'); Rose-DateTime-0.540/t/locale.t000644 000765 000120 00000001330 10760063453 016077 0ustar00johnadmin000000 000000 #!/usr/bin/perl -w use strict; use Test::More tests => 7; BEGIN { use_ok('Rose::DateTime::Util'); use_ok('DateTime'); } Rose::DateTime::Util->import('parse_date'); Rose::DateTime::Util->european_dates(undef); # re-init my $d = parse_date('03-05-2003'); is($d->month, 3, 'locale 1'); DateTime->DefaultLocale('de'); $d = parse_date('03-05-2003'); is($d->month, 3, 'locale 2'); Rose::DateTime::Util->european_dates(undef); # re-init $d = parse_date('03-05-2003'); is($d->month, 5, 'locale 3'); is(Rose::DateTime::Util->european_dates, 1, 'european_dates check'); DateTime->DefaultLocale('en_US'); Rose::DateTime::Util->european_dates(undef); # re-init $d = parse_date('03-05-2003'); is($d->month, 3, 'locale 4'); Rose-DateTime-0.540/t/parser.t000755 000765 000120 00000003635 10760063453 016151 0ustar00johnadmin000000 000000 #!/usr/bin/perl -w use strict; use Test::More tests => 13; BEGIN { use_ok('Rose::DateTime::Util'); use_ok('Rose::DateTime::Parser'); } # Test to see if we can creat local DateTimes eval { DateTime->now(time_zone => 'local') }; # Use UTC if we can't Rose::DateTime::Util->time_zone('UTC') if($@); my $default_parser = Rose::DateTime::Parser->new(); is($default_parser->time_zone, Rose::DateTime::Util->time_zone, 'time_zone()'); my $d1 = $default_parser->parse_date('1/1/2002'); my $d2 = Rose::DateTime::Util::parse_date('1/1/2002', 'floating'); ok($d1 == $d2, 'parse_date() 1'); my $floating_parser = Rose::DateTime::Parser->new(time_zone => 'floating'); $d1 = $floating_parser->parse_date('1/1/2002'); $d2 = Rose::DateTime::Util::parse_date('1/1/2002', 'floating'); ok($d1 == $d2, 'parse_date() 2'); is($default_parser->european, 0, 'european 1'); is($floating_parser->european, 0, 'european 2'); Rose::DateTime::Util->european_dates(1); $d1 = $default_parser->parse_date('1/2/2002'); $d2 = Rose::DateTime::Util::parse_date('2/1/2002'); ok($d1 == $d2, 'parse_date() 3'); $default_parser->european(1); $d1 = $default_parser->parse_date('2/1/2002'); $d2 = Rose::DateTime::Util::parse_date('2/1/2002'); ok($d1 == $d2, 'parse_date() 4'); Rose::DateTime::Util->european_dates(0); $d1 = $default_parser->parse_date('2/1/2002'); $d2 = Rose::DateTime::Util::parse_date('1/2/2002'); ok($d1 == $d2, 'parse_date() 5'); Rose::DateTime::Util->european_dates(1); $default_parser->european(undef); $d1 = $default_parser->parse_date('2/1/2002'); $d2 = Rose::DateTime::Util::parse_date('2/1/2002'); ok($d1 == $d2, 'parse_date() 6'); $default_parser->european(0); $d1 = $default_parser->parse_date('1/2/2002'); $d2 = Rose::DateTime::Util::parse_date('2/1/2002'); ok($d1 == $d2, 'parse_date() 7'); $d1 = $default_parser->parse_european_date('2/1/2002'); $d2 = Rose::DateTime::Util::parse_date('2/1/2002'); ok($d1 == $d2, 'parse_date() 8'); Rose-DateTime-0.540/t/pod.t000755 000765 000120 00000000253 10760063453 015430 0ustar00johnadmin000000 000000 #!/usr/bin/perl -w use strict; use Test::More; eval 'use Test::Pod 1.00'; plan(skip_all => 'Test::Pod 1.00 required for testing POD') if($@); all_pod_files_ok(); Rose-DateTime-0.540/lib/Rose/000750 000765 000120 00000000000 12251103544 015655 5ustar00johnadmin000000 000000 Rose-DateTime-0.540/lib/Rose/DateTime/000750 000765 000120 00000000000 12251103544 017351 5ustar00johnadmin000000 000000 Rose-DateTime-0.540/lib/Rose/DateTime.pm000755 000765 000120 00000002343 12251103506 017717 0ustar00johnadmin000000 000000 package Rose::DateTime; use strict; # ha our $VERSION = '0.540'; 1; __END__ =head1 NAME Rose::DateTime - DateTime helper functions and objects. =head1 SYNOPSIS use Rose::DateTime::Util qw(:all); $now = parse_date('now'); $then = parse_date('12/25/2001 6pm'); $date_text = format_date($then, "%D at %T %p"); ... use Rose::DateTime::Parser; $parser = Rose::DateTime::Parser->new(time_zone => 'UTC'); $date = $parser->parse_date('12/25/1999'); =head1 DESCRIPTION The C modules provide a few convenience functions and objects for use with C dates. L contains a simple date parser and a slightly customized date formatter. L encapsulates a date parser with an associated default time zone. This module (C) exists mostly to provide a version number for CPAN. See the individual modules for some actual documentation. =head1 SEE ALSO L, L =head1 AUTHOR John C. Siracusa (siracusa@gmail.com) =head1 LICENSE Copyright (c) 2010 by John C. Siracusa. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Rose-DateTime-0.540/lib/Rose/DateTime/Parser.pm000755 000765 000120 00000011510 11352004505 021147 0ustar00johnadmin000000 000000 package Rose::DateTime::Parser; use strict; use Rose::DateTime::Util(); use Rose::Object; our @ISA = qw(Rose::Object); use Rose::Object::MakeMethods::Generic ( scalar => 'error', 'scalar --get_set_init' => 'time_zone', ); our $VERSION = '0.50'; sub init_time_zone { Rose::DateTime::Util->time_zone } sub init_european { Rose::DateTime::Util->european_dates } sub european { my($self) = shift; if(@_) { if(defined $_[0]) { return $self->{'european'} = $_[0] ? 1 : 0; } else { $self->{'european'} = undef } } return $self->{'european'} if(defined $self->{'european'}); $self->{'european'} = $self->init_european; } sub parse_date { my($self) = shift; my $date; if($self->european) { $date = Rose::DateTime::Util::parse_european_date(shift, $self->time_zone); } else { local $Rose::DateTime::Util::European_Dates = 0; $date = Rose::DateTime::Util::parse_date(shift, $self->time_zone); } return $date if($date); $self->error(Rose::DateTime::Util->error); return $date; } *parse_datetime = \&parse_date; sub parse_european_date { my($self) = shift; my $date = Rose::DateTime::Util::parse_european_date(shift, $self->time_zone); return $date if($date); $self->error(Rose::DateTime::Util->error); return $date; } 1; __END__ =head1 NAME Rose::DateTime::Parser - DateTime parser object. =head1 SYNOPSIS use Rose::DateTime::Parser; $parser = Rose::DateTime::Parser->new(time_zone => 'UTC'); $dt = $parser->parse_date('4/30/2001 8am') or warn $parser->error; =head1 DESCRIPTION L encapsulates a particular kind of call to L's L and L functions. The object maintains the desired time zone, which is then passed to each call. This class inherits from, and follows the conventions of, L. See the L documentation for more information. =head1 CONSTRUCTOR =over 4 =item B Constructs a new L object based on PARAMS, where PARAMS are name/value pairs. Any object method is a valid parameter name. =back =head1 OBJECT METHODS =over 4 =item B Get or set the error message string. =item B Get or set a boolean value that controls how the L method will interpret "xx/xx/xxxx" dates: either month/day/year or year/month/day. If true, then the L method will pass its arguments to L's L function, which interprets such dates as "dd/mm/yyyy". If false, then the L method will temporarily B non-European date parsing and then call L's L function, which will interpret the date as "mm/dd/yyyy". This attribute defaults to the value returned by the Leuropean_dates|Rose::DateTime::Util/european_dates> class method called I object is constructed>. If the BOOL argument is undefined (instead of "false, but defined") then the attribute will return to its default value by calling the Leuropean_dates|Rose::DateTime::Util/european_dates> class method again. To unambiguously set the attribute to true or false, pass a defined value like 1 or 0. =item B Attempt to parse STRING by passing it to L's L or L function. The choice is controlled by the L attribute. If parsing is successful, the resulting L object is returned. Otherwise, L is set and false is returned. =item B This method is an alias for L =item B Attempt to parse STRING by passing it to L's L function (regardless of the value of the L attribute). If parsing is successful, the resulting L object is returned. Otherwise, L is set and false is returned. =item B Get or set the time zone string passed to L's L function. Defaults to the value returned by the Ltime_zone|Rose::DateTime::Util/time_zone> class method. =back =head1 AUTHOR John C. Siracusa (siracusa@gmail.com) =head1 LICENSE Copyright (c) 2010 by John C. Siracusa. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Rose-DateTime-0.540/lib/Rose/DateTime/Util.pm000755 000765 000120 00000051157 12251103350 020640 0ustar00johnadmin000000 000000 package Rose::DateTime::Util; use strict; use Carp(); use DateTime; use DateTime::Infinite; require Exporter; our @ISA = qw(Exporter); our @EXPORT_OK = qw(format_date parse_date parse_european_date parse_epoch); our %EXPORT_TAGS = ( std => [ qw(format_date parse_date parse_european_date) ], all => \@EXPORT_OK ); our $VERSION = '0.540'; our $TZ = 'floating'; our $Debug = 0; our $European_Dates = __PACKAGE__->init_european_dates; our $Error; sub error { $Error } sub time_zone { my($class) = shift; return $TZ = shift if(@_); return $TZ; } sub european_dates { my($class) = shift; if(@_) { if(defined $_[0]) { return $European_Dates = $_[0] ? 1 : 0; } return $European_Dates = $class->init_european_dates; } return $European_Dates; } sub init_european_dates { #my($class) = shift; my $locale_class = DateTime->DefaultLocale; unless(ref $locale_class) { $locale_class = DateTime::Locale->load($locale_class); } # Fall back to the older (pre-0.4) DateTime::Locale API my $short = $locale_class->can('date_format_short') ? $locale_class->date_format_short : $locale_class->short_date_format; $short =~ tr{dmyDMY}{}cd; $short =~ tr{dmyDMY}{dmydmy}s; # date_parts_order() is deprecated in DateTime::Locale 0.44+ #if($locale_class->date_parts_order eq 'dmy') if($short eq 'dmy') { return 1; } return 0; } sub parse_european_date { local $European_Dates = 1; &parse_date; # implicitly pass the current args: @_ } sub parse_date { my($arg, $time_zone) = @_; $time_zone ||= $TZ; my($fsecs, $secs, $mins, $hours, $mday, $month, $year, $wday, $yday, $isdst, $month_abbrev, $date, $ampm, $hours2, $ampm2); $Error = undef; no warnings 'uninitialized'; if(ref $arg && $arg->isa('DateTime')) { if(@_ > 1) { my $error; TRY: { local $@; eval { $arg->set_time_zone($time_zone) }; $error = $@; } if($error) { $Error = $error; return undef; } } return $arg; } elsif(($year, $month, $mday, $hours, $mins, $secs, $fsecs, $ampm, $hours2, $ampm2) = ($arg =~ m{ ^ (\d{4}) \s* [-._]? \s* # year (\d{2}) \s* [-._]? \s* # month (\d{2}) # day (?: \s* [-._T]? \s* (?: (\d\d?) : # hour (\d\d) # min (?: (?: : (\d\d) )? (?: \. (\d{0,9}) )? )? # sec? nanosec? (?: \s* ([aApP]\.?[mM]\.?) )? # am/pm? | (\d\d?) # hour (?: \s* ([aApP]\.?[mM]\.?) ) # am/pm ) )? $ }x)) { # yyyy mm dd [hh:mm[:ss[.nnnnnnnnn]]] [am/pm] also valid w/o spaces or w/ hyphens $hours = $hours2 if(defined $hours2); $ampm = $ampm2 if(defined $ampm2); $date = _timelocal($secs, $mins, $hours, $mday, $month, $year, $ampm, $fsecs, $time_zone); } elsif(($month, $mday, $year, $hours, $mins, $secs, $fsecs, $ampm) = ($arg =~ m{ ^ (\d{1,2}) [-/._] (\d{1,2}) [-/._] (\d{4}) # xx-xx-yyyy (?: (?: \s+ | [-._T] ) (\d\d?) # hour (?::(\d\d)(?::(\d\d))?)?(?:\.(\d{0,9}))? # min? sec? nanosec? (?:\s*([aApP]\.?[mM]\.?))? # am/pm )? $ }x)) { # Normal: mm/dd/yyyy, mm-dd-yyyy, mm.dd.yyyy [hh:mm[:ss][.nnnnnnnnn]] [am/pm] # European: dd/mm/yyyy, dd-mm-yyyy, dd.mm.yyyy [hh:mm[:ss][.nnnnnnnnn]] [am/pm] if($European_Dates) { ($mday, $month) = ($month, $mday); # swap month and day in Euro-mode } $date = _timelocal($secs, $mins, $hours, $mday, $month, $year, $ampm, $fsecs, $time_zone); } elsif(lc $arg eq 'now' || lc $arg eq 'now!') { # Right now return DateTime->now(time_zone => $time_zone); } elsif($arg =~ /^(?: (-?\d+)(?:\.(\d{0,9}))? | (-?\d*)\.(\d{1,9}) )$/x) { my $epoch = defined $1 ? $1 : $3; my $fsecs = defined $2 ? $2 : $4; $epoch = 0 if($epoch eq '-'); # In Unix time format (guessing) $date = DateTime->from_epoch(epoch => $epoch || 0, time_zone => $time_zone); if($fsecs) { my $len = length $fsecs; if($len < 9) { $fsecs .= ('0' x (9 - length $fsecs)); } elsif($len > 9) { $fsecs = substr($fsecs, 0, 9); } $date->set(nanosecond => $fsecs); } return $date; } elsif($arg =~ /^today$/i) { $date = DateTime->now(time_zone => $time_zone); $date->truncate(to => 'day'); } elsif($arg =~ /^(-)?infinity$/i) { if($1) { return DateTime::Infinite::Past->new; } return DateTime::Infinite::Future->new; } else { $Error = "Could not parse date: $arg" . (($Error) ? " - $Error" : ''); return undef; } unless($date) { $Error = "Could not parse date: $arg" . (($Error) ? " - $Error" : ''); return undef; } return $date; } sub parse_epoch { my($arg, $time_zone) = @_; $time_zone ||= $TZ; $Error = undef; my $date; no warnings 'uninitialized'; if($arg =~ /^(?: (-?\d+)(?:\.(\d{0,9}))? | (-?\d*)\.(\d{1,9}) )$/x) { my $epoch = defined $1 ? $1 : $3; my $fsecs = defined $2 ? $2 : $4; $epoch = 0 if($epoch eq '-'); # In Unix time format (guessing) $date = DateTime->from_epoch(epoch => $epoch || 0, time_zone => $time_zone); if($fsecs) { my $len = length $fsecs; if($len < 9) { $fsecs .= ('0' x (9 - length $fsecs)); } elsif($len > 9) { $fsecs = substr($fsecs, 0, 9); } $date->set(nanosecond => $fsecs); } return $date; } else { return parse_date(@_); } unless($date) { $Error = "Could not parse epoch: $arg" . (($Error) ? " - $Error" : ''); return undef; } return $date; } sub format_date { my($date, @formats) = @_; my(@localtime, %formats, @ret, $ret); return undef unless(defined $date); #return $date if($date =~ /^-?infinity$/i); unless(ref $date && $date->isa('DateTime')) { Carp::croak("format_date() requires a DateTime object as its first argument"); } return '-infinity' if($date->isa('DateTime::Infinite::Past')); return 'infinity' if($date->isa('DateTime::Infinite::Future')); foreach my $format (@formats) { $format =~ s/%t/%l:%M:%S %p/g; # strftime() treats %t as a \t # Formats not handled by strftime() if($format =~ /%[EFf]/) { unless(%formats) { my $date_word; my $mday = $date->day; #if($mday =~ /([^1]|^)1$/) { $date_word = $mday . 'st' } #elsif($mday =~ /([^1]|^)2$/) { $date_word = $mday . 'nd' } #elsif($mday =~ /([^1]|^)3$/) { $date_word = $mday . 'rd' } #else { $date_word = $mday . 'th' } # Requires a reasonably modern perl if($mday =~ /(? $mday, # DateTime snagged this one '%E' => $date_word, '%F' => $date->strftime("%A, %B $date_word %Y"), '%f' => $date->month + 0, ); } $format =~ s/(%[eEFf])/$formats{$1}/g; } push(@ret, $date->strftime($format)); } return wantarray ? @ret : join(' ', @ret); } # # Internal Subroutines # sub _timelocal { my($secs, $mins, $hours, $mday, $month, $year, $ampm, $fsecs, $tz) = @_; my($date); $hours = 0 unless(defined($hours)); if(defined $fsecs) { my $len = length $fsecs; if($len < 9) { $fsecs .= ('0' x (9 - length $fsecs)); } elsif($len > 9) { $fsecs = substr($fsecs, 0, 9); } } else { $fsecs = 0; } $secs = 0 unless(defined $secs); $mins = 0 unless(defined $mins); if($ampm) { if($ampm =~ /^p/i) { $hours += 12 unless($hours == 12); } elsif($hours == 12) { $hours = 0; } } my $error; TRY: { local $@; eval { $date = DateTime->new(year => $year, month => $month, day => $mday, hour => $hours, minute => $mins, second => $secs, nanosecond => $fsecs, time_zone => $tz); }; $error = $@; } if($error) { $Error = $error; warn $Error if($Debug); # $ENV{'MOD_PERL'} return; } return $date; } 1; # Can't figure out how to hide comments like this from search.cpan.org's # POD-to-HTML translator... # =begin comment # B The local time zone may not be known on all systems (in # particular, Win32 systems). If you are on such a system, you will encounter a # fatal error if C tries to construct a L object with # a time zone of "local". # # See the L documentation for information on the various # ways to successfully indicate your local time zone, or set a different default # time zone for this class by calling # Ltime_zone(...)> with a new time zone as an # argument. # =end comment __END__ =head1 NAME Rose::DateTime::Util - Some simple DateTime wrapper functions. =head1 SYNOPSIS use Rose::DateTime::Util qw(:all); $now = parse_date('now'); $then = parse_date('12/25/2001 11pm'); print $now->day_of_week; # e.g., "Monday" # "December 25th 2001 at 11:00:00 PM" $date_text = format_date($then, "%B %E %Y at %t"); =head1 DESCRIPTION L is a thin wrapper around L that provides a very simple date parser and a few extra date formatting options. =head1 EXPORTS L does not export any function names by default. The 'all' tag: use Rose::DateTime::Util qw(:all); will cause the following function names to be imported: format_date() parse_date() parse_epoch() parse_european_date() =head1 CLASS METHODS =over 4 =item B Returns a message describing the last error that occurred. =item B Get or set a boolean flag that determines how "xx/xx/xxxx" dates are parsed by the L function. If set to a false-but-defined value, then such dates are parsed as "mm/dd/yyyy". If set to true, then they're parsed as "dd/mm/yyyy". If set to undef, then the attribute resets to its initial value, which is determined as described below. The initial value of this attribute is chosen based on the current locale as stored in L's L setting. This initial value is looked up only once. Any subsequent changes to L's L setting will be ignored until/unless this attribute is reset to undef. =item B Get or set the default time zone. This value is passed to Lnew(...)|DateTime> as the value of the C parameter when L creates the L object that it returns. The default value is "floating". =back =head1 FUNCTIONS =over 4 =item B Takes a L object and a list of format strings. In list context, it returns a list of strings with the formats interpolated. In scalar context, it returns a single string constructed by joining all of the list-context return values with single spaces. Examples: # $s = 'Friday 5PM' $s = format_date(parse_date('1/23/2004 17:00'), '%A, %I%p'); # @s = ('Friday', 5, 'PM') @s = format_date(parse_date('1/23/2004 17:00'), '%A', '%I', '%p'); # $s = 'Friday 5 PM' $s = format_date(parse_date('1/23/2004 17:00'), '%A', '%I', '%p'); Returns undef on failure, or if passed an undefined value for DATETIME. An exception will be raised if the DATETIME argument is defined, but is not a L object. The supported formats are mostly based on those supported by L's C method. L calls L's C method when interpolating these formats. Note that the C<%t> and C<%F> formats are I passed to C, but are handled by L instead. See the "Non-standard formats" section below. The C-compatible formats listed below have been transcribed from the L documentation for the sake of convenience, but the L documentation is the definitive source. Using any format strings not in the C-compatible set will be slightly slower. B-compatible formats> =over 4 =item * %a The abbreviated weekday name. =item * %A The full weekday name. =item * %b The abbreviated month name. =item * %B The full month name. =item * %c The default datetime format for the object's locale. =item * %C The century number (year/100) as a 2-digit integer. =item * %d The day of the month as a decimal number (range 01 to 31). =item * %D Equivalent to %m/%d/%y. This is not a good standard format if you have want both Americans and Europeans to understand the date! =item * %e Like %d, the day of the month as a decimal number, but a leading zero is replaced by a space. =item * %G The ISO 8601 year with century as a decimal number. The 4-digit year corresponding to the ISO week number (see %V). This has the same format and value as %y, except that if the ISO week number belongs to the previous or next year, that year is used instead. (TZ) =item * %g Like %G, but without century, i.e., with a 2-digit year (00-99). =item * %h Equivalent to %b. =item * %H The hour as a decimal number using a 24-hour clock (range 00 to 23). =item * %I The hour as a decimal number using a 12-hour clock (range 01 to 12). =item * %j The day of the year as a decimal number (range 001 to 366). =item * %k The hour (24-hour clock) as a decimal number (range 0 to 23); single digits are preceded by a blank. (See also %H.) =item * %l The hour (12-hour clock) as a decimal number (range 1 to 12); single digits are preceded by a blank. (See also %I.) =item * %m The month as a decimal number (range 01 to 12). =item * %M The minute as a decimal number (range 00 to 59). =item * %n A newline character. =item * %N The fractional seconds digits. Default is 9 digits (nanoseconds). %3N milliseconds (3 digits) %6N microseconds (6 digits) %9N nanoseconds (9 digits) =item * %p Either `AM' or `PM' according to the given time value, or the corresponding strings for the current locale. Noon is treated as `pm' and midnight as `am'. =item * %P Like %p but in lowercase: `am' or `pm' or a corresponding string for the current locale. =item * %r The time in a.m. or p.m. notation. In the POSIX locale this is equivalent to `%I:%M:%S %p'. =item * %R The time in 24-hour notation (%H:%M). (SU) For a version including the seconds, see %T below. =item * %s The number of seconds since the epoch. =item * %S The second as a decimal number (range 00 to 61). =item * %T The time in 24-hour notation (%H:%M:%S). =item * %u The day of the week as a decimal, range 1 to 7, Monday being 1. See also %w. =item * %U The week number of the current year as a decimal number, range 00 to 53, starting with the first Sunday as the first day of week 01. See also %V and %W. =item * %V The ISO 8601:1988 week number of the current year as a decimal number, range 01 to 53, where week 1 is the first week that has at least 4 days in the current year, and with Monday as the first day of the week. See also %U and %W. =item * %w The day of the week as a decimal, range 0 to 6, Sunday being 0. See also %u. =item * %W The week number of the current year as a decimal number, range 00 to 53, starting with the first Monday as the first day of week 01. =item * %x The default date format for the object's locale. =item * %X The default time format for the object's locale. =item * %y The year as a decimal number without a century (range 00 to 99). =item * %Y The year as a decimal number including the century. =item * %z The time-zone as hour offset from UTC. Required to emit RFC822-conformant dates (using "%a, %d %b %Y %H:%M:%S %z"). =item * %Z The time zone or name or abbreviation. =item * %% A literal `%' character. =item * %{method} Any method name may be specified using the format C<%{method}> name where "method" is a valid L object method. =back B =over 4 =item * %E Day of the month word (1st, 2nd, 3rd, ... 31st) =item * %f Month number (1, 2, 3, ... 12) =item * %F "%A, %B %E %Y" (Wednesday, April 4th 2001) =item * %i Hour, 12-hour (1, 2, 3, ... 12) =item * %t Time as "%l:%M:%S %p" (1:23:45 PM) =back =item B This function works the same as the L function, except it forces L date parsing. In other words, this: parse_european_date($date, $tz); is equivalent to this: # Save old value of the European date setting my $save = Rose::DateTime::Util->european_dates; # Turn European date parsing on Rose::DateTime::Util->european_dates(1); # Parse the date parse_date($date, $tz); # Restore the old European date setting Rose::DateTime::Util->european_dates($save); =item B Attempts to parse the date described by TEXT. Returns a L object, or undef on failure, with an error message available via Lerror()|/error>. If a L object is passed in place of the TEXT argument, it is returned as-is if there is no TIMEZONE argument, or after having L called on it if there is a TIMEZONE argument. Since the time zone is not part of any of the supported date string formats, L takes an optional TIMEZONE argument which is passed to the L constructor as the value of the C parameter. In the absence of a TIMEZONE argument to C, the time zone defaults to the value returned by the L class method ("floating", by default) The formats understood and their interpretations are listed below. Square brackets are used to indicate optional portions of the formats. =over 4 =item now Right now. Also valid with an exclamation point: "now!" =item today Today, at 00:00:00. =item yyyy mm dd =item yyyy mm dd [hh? am/pm] =item yyyy mm dd [hh?:mm [am/pm]] =item yyyy mm dd [hh?:mm:ss [am/pm]] =item yyyy mm dd [hh?:mm:ss.nnnnnnnnn [am/pm]] Exact date and time. Also valid without spaces, with hyphens ("-"), periods ("."), or underscores ("_") between the year, month, and day, and with a "T", hyphen, period, or underscore between the date and time. The time is optional and defaults to 00:00:00. The am/pm part is optional unless only the "hh" (hours) part of the time is specified. Fractional seconds take a maximum of 9 digits, but fewer are also acceptable. =item mm/dd/yyyy [hh[:mm[:ss[.nnnnnnnnn]]]] [am/pm] Exact date and time. Also valid with hyphens ("-"), periods ("."), or underscores ("_") instead of slashes ("/"), and with a "T", hyphen, period, or underscore between the date and time. The time is optional and defaults to 00:00:00. The am/pm part is optional. Fractional seconds take a maximum of 9 digits, but fewer are also acceptable. This format is only valid when L is set to B (which is the default). =item dd/mm/yyyy [hh[:mm[:ss[.nnnnnnnnn]]]] [am/pm] Exact date and time. Also valid with hyphens ("-"), periods ("."), or underscores ("_") instead of slashes ("/"). The time is optional and defaults to 00:00:00. The am/pm part is optional. Fractional seconds take a maximum of 9 digits, but fewer are also acceptable. This format is only valid when L is set to B. =item [-]infinity Positive or negative infinity. Case insensitive. =item [-]dddddddddd[.nnnnnnnnn] seconds) A positive or negative number with optional fractional seconds is interpreted as seconds since the Unix epoch. Fractional seconds take a maximum of 9 digits, but fewer are also acceptable. =back =item B This function is the same as L except that it prefers Unix epoch values in cases where this format conflicts with another. Example: $arg = '19991231'; $dt = parse_date($arg); # Dec 31, 1999 $dt = parse_epoch($arg); # Aug 20, 1970 =back =head1 SEE ALSO L, L =head1 AUTHOR John C. Siracusa (siracusa@gmail.com) =head1 LICENSE Copyright (c) 2010 by John C. Siracusa. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.