Time-ParseDate-2026.0219/000755 000765 000024 00000000000 15150360352 015372 5ustar00jbrandtstaff000000 000000 Time-ParseDate-2026.0219/inc/000755 000765 000024 00000000000 15150360352 016143 5ustar00jbrandtstaff000000 000000 Time-ParseDate-2026.0219/Changes000644 000765 000024 00000017757 15150357775 016725 0ustar00jbrandtstaff000000 000000 Revision history for Perl module Time::ParseDate 2026.0219 2026-02-19 - Add support for trailing Z/z as UTC in ISO 8601 timestamps. From Kai Storbeck. https://github.com/muir/Time-modules/pull/10 - Update minimum perl version to 5.8.1 for all modules. - Update new AUTHOR, keeping credit for previous authors (thanks to all!) - Update the custom license to "same as Perl" for all - README is now generated from the POD 2015.1030 2015-10-30 - Not requirement for Time::Piece for tests. 2015.0925 2015-09-25 - https://rt.cpan.org/Ticket/Display.html?id=96453 fix epoch second 0 with timezone. 2015.0925 2015-09-25 - apply patch from bug https://rt.cpan.org/Ticket/Display.html?id=90367 use Time::Piece in place of POSIX tzset for better compatibility with Windows. 2015.0925 2015-09-25 - apply patch from bug https://rt.cpan.org/Ticket/Display.html?id=96031 manpage typo patch 2013.1113 2013-11-13 - fix bug https://rt.cpan.org/Ticket/Display.html?id=90343 "Month day, year" wasn't parsing correctly. 2013.0920 2013-09-20 - Skip tests when tzset isn't available - Type-o fixes 2013.0917 2013-09-17 - Replaced CHANGELOG with Changes file. 2013.0916 2013-09-16 - Module NAME changed to Time::ParseDate. Change requested by David Steinbrunner. 2013.0913 2013-09-13 - Changed date terminator to accept many more characters (not just whitespace. Fixing: https://rt.cpan.org/Ticket/Display.html?id=87828 - Added "Sept" as an abbr for September. Fixing: https://rt.cpan.org/Ticket/Display.html?id=87451 - Parse subsecond strings longer than six digits. Can only return about four digits though. https://rt.cpan.org/Ticket/Display.html?id=79740 2013.0912 2013-09-12 - Pulled fix from Adam Schobelock that removes timezone offset caching because it was creating incorrect behavor or Moscow. 2011.0517 2011-05-17 - Bugfix from Sophie Hamilton: call tzset() when changing timezones. - Bugfix: bail out of tests cleanly when tzset doesn't work. 2011.0505 2011-05-05 - Bugfix: make sure $ampm is defined so no undefined string warnings are issued. - Honor the GMT flag when parsing time specs. Patch from kris at shannon.id.au. - Bugfix: RT#31477 noon & midnight would match in the middle of strings. - Added %v conversion for Time::CTime - Added tests to disprove invalid bug reports. 2006.0814 2006-08-14 - A bugfix for negative offsets that overflowed (from Vernon Lyon ) - Add a few more timezones (from Peter Ludemann and Alex Bowley ) - Recognize fractional times counts like "1.5 minutes ago" (from Simon Wistow ) - Recognize Dow "before last" (from Ole Craig ) - Change various __DATA__ to __END__ (from Nick Ing-Simmons ) 2003.1125 2003-11-25 - Various folks have complained that JulianDay isn't correct. An errata section has been added to the documentation. - Mark Ivey add '@' as a synonym for 'at'. Fixed typos. - Bryan Henderson sent in a patch to allow NOW => 0 so that ParseDate can be used to parse relative times. - ewan@baremetal.com sent in a patch adding a bit of ISO 8601 support. - David Alban doesn't like allowing the hour 24:00. I agree. Gone if you have VALIDATE=>1. - Still to be done: the support the large number of ISO 8601 date formats: http://hydracen.com/dx/iso8601.htm 2003.0211 2003-02-11 - Mike Cramer sent a patch to Timezone to handle changes in $ENV{TZ}. - Rani Pinchuk sent in a definition for the CEST timezone. - On Phil.Moore@msdw.com's behalf the timezone 'MET DST' is now supported. 2002.1001 2002-10-01 - No real changes, just added a license. 101.062001 2001-06-20 - Paul Zimmer found that '7/17/01' with PREFER_FUTURE failed badly. Fixed. This was also submitted by Dana Burd . - Ben Daglish noted that array context was implying WHOLE and DATE_REQUIRED. Fixed. - Streppone Cosimo requested support for postgresql's date format ("dd/mm/yyyy hh:mn:ss +tzo") - Ameeth Linus Daniel found that IST wasn't a defined timezone. I've defined it as +0530, but I'm not positive that's correct. - Gautam Tripathi sent in a fix for timezone offset calculations making them consistent across all systems (no more problems with differing interpretations of negative modulus operations). - Mike Nerone requested the syntax "4 days ago". He says that that syntax is suppored by GNU date. This was also requested by Townsend, John E. . - Anton Berezin notice that ParseDate couldn't handle "Sunday, 06-Nov-94 08:49:37 GMT" and sent in a patch. 100.010301 2000-01-03 - W. Phillip Moore reproted a Y2K bug: it could not parse 'Jan 1 2000 10:30:30AM'. Fixed. This is embarassing beasue sent in a patch Dec 9th! 99.111701 1999-11-17 - Allen Smith noticed that VALIDATE wouldn't accept hours > 0... - Hugh C Kennedy contributed patches to parse months like `Jan.' in additon to `Jan' and `January'. 99.062401 1999-06-24: - Randy Kobes sent in a fix for Timezone.pm that allows all tests to pass on MSWin32. 99.062301: - Eric Prestemon noticed that %y would print "0" in 2000, not "00" as it should. Fixed. - Parsedate() now checks for wantarray() and returns what remains of its input when called from array context. - Added another parsing option: VALIDATE. When VALIDATE is set, silly values for hours, months, etc will be rejected. Like the 32nd of December will no longer be new years day. 99.062201 1999-06-22 - Optionally return fractional seconds from ParseDate (including the SYBASE formatted ones). Provide for printing fractional seconds in CTime. Changes from Douglas Wegscheid 99.061601 1999-06-16 - More attempts to support systems whose time function isn't centered around Jan 1, 1970 midnight GMT. 99.061501 1999-05-15 - Fixed a couple of compiler warnings. Did extensive testing with dates beyond 2000 and before 1970. Quite a few code changes. Old code would have worked in many > 2000 cases but broke terribly for dates < 1970. New code should work until year 10k. Well, there's one problem: unix time format is only 32 bits, signed. 98.112901 1998-11-29 - Slight change to avoid an "Use of uninitialized value" error pointed out by Mike Coffin . 98.112801 1998-11-12 - It turns out that Sybase emits time values like "3:09:59:000PM". The last three digits are milliseconds. Such times are now recognized but the milliseconds are ignored. Change requested by ryanmcleish . - Corrected the documenation on strftime conversions for %d and %e. The code and the documentation now agree: %d - 01 to 31 %e - 1 to 31 98.052201 1998-05-22 - Minor bugfix: didn't recognize 5/18/1998. 97.092101 1997-09-21 - Fix a 5.004 warning. - Add support for "June 4, 1997" 96.110801 1996-11-08 - Added support for negative relative times. - Bugfix: "now" by itself was ignored. - Bugfix: could not combine "now" with time offsets (only date offsets) 96.032801 1996-03-28 - Added support for "TZN 96.032702 1996-03-27 - This is the first release to use the Makefile.PL packaging. There are many changes with repect to previous releases. All modules now running with -w and use strict. - CTime.pm: should be faster - ParseDate.pm: core logic changed, more dates parsed. - datetime.t: more tests - Timezone.pm: ripped out tzset code and replaced it with code from Graham Barr Time-ParseDate-2026.0219/MANIFEST000644 000765 000024 00000001025 15150357775 016540 0ustar00jbrandtstaff000000 000000 Changes inc/Module/Install.pm inc/Module/Install/Base.pm inc/Module/Install/Can.pm inc/Module/Install/Fetch.pm inc/Module/Install/Makefile.pm inc/Module/Install/Metadata.pm inc/Module/Install/ReadmeFromPod.pm inc/Module/Install/Win32.pm inc/Module/Install/WriteAll.pm lib/Time/CTime.pm lib/Time/DaysInMonth.pm lib/Time/JulianDay.pm lib/Time/ParseDate.pm lib/Time/Timezone.pm Makefile.PL MANIFEST MANIFEST.SKIP META.yml Module meta-data (added by MakeMaker) README t/datetime.t t/dst.t t/metdate.t t/order1.t t/order2.t t/rt96453.t Time-ParseDate-2026.0219/t/000755 000765 000024 00000000000 15150360352 015635 5ustar00jbrandtstaff000000 000000 Time-ParseDate-2026.0219/README000644 000765 000024 00000012520 15150357775 016271 0ustar00jbrandtstaff000000 000000 NAME Time::ParseDate -- date parsing both relative and absolute SYNOPSIS use Time::ParseDate; $seconds_since_jan1_1970 = parsedate("12/11/94 2pm", NO_RELATIVE => 1) $seconds_since_jan1_1970 = parsedate("12/11/94 2pm", %options) OPTIONS Date parsing can also use options. The options are as follows: FUZZY -> it's okay not to parse the entire date string NOW -> the "current" time for relative times (defaults to time()) ZONE -> local timezone (defaults to $ENV{TZ}) WHOLE -> the whole input string must be parsed GMT -> input time is assumed to be GMT, not localtime UK -> prefer UK style dates (dd/mm over mm/dd) DATE_REQUIRED -> do not default the date TIME_REQUIRED -> do not default the time NO_RELATIVE -> input time is not relative to NOW TIMEFIRST -> try parsing time before date [not default] PREFER_PAST -> when year or day of week is ambiguous, assume past PREFER_FUTURE -> when year or day of week is ambiguous, assume future SUBSECOND -> parse fraction seconds VALIDATE -> only accept normal values for HHMMSS, YYMMDD. Otherwise days like -1 might give the last day of the previous month. DATE FORMATS RECOGNIZED Absolute date formats Dow, dd Mon yy Dow, dd Mon yyyy Dow, dd Mon dd Mon yy dd Mon yyyy Month day{st,nd,rd,th}, year Month day{st,nd,rd,th} Mon dd yyyy yyyy/mm/dd yyyy-mm-dd (usually the best date specification syntax) yyyy/mm mm/dd/yy mm/dd/yyyy mm/yy yy/mm (only if year > 12, or > 31 if UK) yy/mm/dd (only if year > 12 and day < 32, or year > 31 if UK) dd/mm/yy (only if UK, or an invalid mm/dd/yy or yy/mm/dd) dd/mm/yyyy (only if UK, or an invalid mm/dd/yyyy) dd/mm (only if UK, or an invalid mm/dd) Relative date formats: count "days" count "weeks" count "months" count "years" Dow "after next" Dow "before last" Dow (requires PREFER_PAST or PREFER_FUTURE) "next" Dow "tomorrow" "today" "yesterday" "last" dow "last week" "now" "now" "+" count units "now" "-" count units "+" count units "-" count units count units "ago" Absolute time formats: hh:mm:ss[.ddd] hh:mm hh:mm[AP]M hh[AP]M hhmmss[[AP]M] "noon" "midnight" Relative time formats: count "minutes" (count can be franctional "1.5" or "1 1/2") count "seconds" count "hours" "+" count units "+" count "-" count units "-" count count units "ago" Timezone formats: [+-]dddd GMT[+-]d+ [+-]dddd (TZN) TZN Special formats: [ d]d/Mon/yyyy:hh:mm:ss [[+-]dddd] yy/mm/dd.hh:mm DESCRIPTION This module recognizes the above date/time formats. Usually a date and a time are specified. There are numerous options for controlling what is recognized and what is not. The return code is always the time in seconds since January 1st, 1970 or undef if it was unable to parse the time. If a timezone is specified it must be after the time. Year specifications can be tacked onto the end of absolute times. If "parsedate()" is called from array context, then it will return two elements. On successful parses, it will return the seconds and what remains of its input string. On unsuccessful parses, it will return "undef" and an error string. EXAMPLES $seconds = parsedate("Mon Jan 2 04:24:27 1995"); $seconds = parsedate("Tue Apr 4 00:22:12 PDT 1995"); $seconds = parsedate("04.04.95 00:22", ZONE => PDT); $seconds = parsedate("Jan 1 1999 11:23:34.578", SUBSECOND => 1); $seconds = parsedate("122212 950404", ZONE => PDT, TIMEFIRST => 1); $seconds = parsedate("+3 secs", NOW => 796978800); $seconds = parsedate("2 months", NOW => 796720932); $seconds = parsedate("last Tuesday"); $seconds = parsedate("Sunday before last"); ($seconds, $remaining) = parsedate("today is the day"); ($seconds, $error) = parsedate("today is", WHOLE=>1); AUTHOR Best Practical Solutions, LLC ORIGINAL AUTHOR David Muir Sharnoff BUGS All bugs should be reported via email to L or via the web at L. LICENSE AND COPYRIGHT Copyright (C) 1996-2010 David Muir Sharnoff. Copyright (C) 2011 Google, Inc. Copyright (C) 2026 Best Practical Solutions, LLC. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Time-ParseDate-2026.0219/MANIFEST.SKIP000644 000765 000024 00000002624 15150357775 017313 0ustar00jbrandtstaff000000 000000 #!start included /Users/jbrandt/perl5/perlbrew/perls/perl-5.34.3/lib/5.34.3/ExtUtils/MANIFEST.SKIP # Avoid version control files. \bRCS\b \bCVS\b \bSCCS\b ,v$ \B\.svn\b \B\.git\b ^\.github\b \B\.gitignore\b \b_darcs\b \B\.cvsignore$ # Avoid VMS specific MakeMaker generated files \bDescrip.MMS$ \bDESCRIP.MMS$ \bdescrip.mms$ # Avoid Makemaker generated and utility files. \bMANIFEST\.bak \bMakefile$ \bblib/ \bMakeMaker-\d \bpm_to_blib\.ts$ \bpm_to_blib$ \bblibdirs\.ts$ # 6.18 through 6.25 generated this \b_eumm/ # 7.05_05 and above # Avoid Module::Build generated and utility files. \bBuild$ \b_build/ \bBuild.bat$ \bBuild.COM$ \bBUILD.COM$ \bbuild.com$ # and Module::Build::Tiny generated files \b_build_params$ # Avoid temp and backup files. ~$ \.old$ \#$ \b\.# \.bak$ \.tmp$ \.# \.rej$ \..*\.sw.?$ # Avoid OS-specific files/dirs # Mac OSX metadata \B\.DS_Store # Mac OSX SMB mount metadata files \B\._ # Placeholder files created when iCloud will "optimize Mac storage" \.i[cC]loud$ # Avoid Devel::Cover and Devel::CoverX::Covered files. \bcover_db\b \bcovered\b # Avoid prove files \B\.prove$ # Avoid MYMETA files ^MYMETA\. # Temp files for new META ^META_new\.(?:json|yml) # Avoid travis-ci.org file ^\.travis\.yml # Avoid AppVeyor file ^\.?appveyor.yml #!end included /Users/jbrandt/perl5/perlbrew/perls/perl-5.34.3/lib/5.34.3/ExtUtils/MANIFEST.SKIP \.claude/settings\.local\.json Time-ParseDate-2026.0219/META.yml000644 000765 000024 00000001212 15150357775 016656 0ustar00jbrandtstaff000000 000000 --- abstract: 'date parsing both relative and absolute' author: - 'Best Practical Solutions, LLC ' build_requires: ExtUtils::MakeMaker: 6.59 Time::Piece: 0 configure_requires: ExtUtils::MakeMaker: 6.59 distribution_type: module dynamic_config: 1 generated_by: 'Module::Install version 1.21' license: perl_5 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Time-ParseDate no_index: directory: - inc - t requires: perl: 5.8.1 resources: license: http://dev.perl.org/licenses/ repository: https://github.com/bestpractical/time-parsedate version: 2026.0219 Time-ParseDate-2026.0219/lib/000755 000765 000024 00000000000 15150360352 016140 5ustar00jbrandtstaff000000 000000 Time-ParseDate-2026.0219/Makefile.PL000644 000765 000024 00000000414 15150357775 017362 0ustar00jbrandtstaff000000 000000 use lib '.'; use inc::Module::Install; name('Time-ParseDate'); all_from('lib/Time/ParseDate.pm'); readme_from('lib/Time/ParseDate.pm'); repository('https://github.com/bestpractical/time-parsedate'); license('perl_5'); build_requires('Time::Piece'); sign; WriteAll; Time-ParseDate-2026.0219/lib/Time/000755 000765 000024 00000000000 15150360352 017036 5ustar00jbrandtstaff000000 000000 Time-ParseDate-2026.0219/lib/Time/ParseDate.pm000644 000765 000024 00000073407 15150357775 021276 0ustar00jbrandtstaff000000 000000 package Time::ParseDate; require 5.008001; use Carp; use Time::Timezone; use Time::JulianDay; require Exporter; @ISA = qw(Exporter); @EXPORT = qw(parsedate); @EXPORT_OK = qw(pd_raw %mtable %umult %wdays); use strict; #use diagnostics; # constants use vars qw(%mtable %umult %wdays $VERSION); $VERSION = 2026.0219; # globals use vars qw($debug); # dynamically-scoped use vars qw($parse); my %mtable; my %umult; my %wdays; my $y2k; CONFIG: { %mtable = qw( Jan 1 Jan. 1 January 1 Feb 2 Feb. 2 February 2 Mar 3 Mar. 3 March 3 Apr 4 Apr. 4 April 4 May 5 Jun 6 Jun. 6 June 6 Jul 7 Jul. 7 July 7 Aug 8 Aug. 8 August 8 Sep 9 Sep. 9 September 9 Sept 9 Oct 10 Oct. 10 October 10 Nov 11 Nov. 11 November 11 Dec 12 Dec. 12 December 12 ); %umult = qw( sec 1 second 1 min 60 minute 60 hour 3600 day 86400 week 604800 fortnight 1209600); %wdays = qw( sun 0 sunday 0 mon 1 monday 1 tue 2 tuesday 2 wed 3 wednesday 3 thu 4 thursday 4 fri 5 friday 5 sat 6 saturday 6 ); $y2k = 946684800; # turn of the century } my $break = qr{(?:\s+|\Z|\b(?![-:.,/]\d))}; sub parsedate { my ($t, %options) = @_; my ($y, $m, $d); # year, month - 1..12, day my ($H, $M, $S); # hour, minute, second my $tz; # timezone my $tzo; # timezone offset my ($rd, $rs); # relative days, relative seconds my $rel; # time&|date is relative my $isspec; my $now = defined($options{NOW}) ? $options{NOW} : time; my $passes = 0; my $uk = defined($options{UK}) ? $options{UK} : 0; local $parse = ''; # will be dynamically scoped. if ($t =~ s#^ ([ \d]\d) / (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) / (\d\d\d\d) : (\d\d) : (\d\d) : (\d\d) (?: [ ] ([-+] \d\d\d\d) (?: \("?(?:(?:[A-Z]{1,4}[TCW56])|IDLE)\))? )? $break ##xi) { #"emacs # [ \d]/Mon/yyyy:hh:mm:ss [-+]\d\d\d\d # This is the format for www server logging. ($d, $m, $y, $H, $M, $S, $tzo) = ($1, $mtable{"\u\L$2"}, $3, $4, $5, $6, $7 ? &mkoff($7) : ($tzo || undef)); $parse .= " ".__LINE__ if $debug; } elsif ($t =~ s#^(\d\d)/(\d\d)/(\d\d)\.(\d\d)\:(\d\d)($break)##) { # yy/mm/dd.hh:mm # I support this format because it's used by wbak/rbak # on Apollo Domain OS. Silly, but historical. ($y, $m, $d, $H, $M, $S) = ($1, $2, $3, $4, $5, 0); $parse .= " ".__LINE__ if $debug; } else { while(1) { if (! defined $m and ! defined $rd and ! defined $y and ! ($passes == 0 and $options{'TIMEFIRST'})) { # no month defined. if (&parse_date_only(\$t, \$y, \$m, \$d, $uk)) { $parse .= " ".__LINE__ if $debug; next; } } if (! defined $H and ! defined $rs) { if (&parse_time_only(\$t, \$H, \$M, \$S, \$tz, %options)) { $parse .= " ".__LINE__ if $debug; next; } } next if $passes == 0 and $options{'TIMEFIRST'}; if (! defined $y) { if (&parse_year_only(\$t, \$y, $now, %options)) { $parse .= " ".__LINE__ if $debug; next; } } if (! defined $tz and ! defined $tzo and ! defined $rs and (defined $m or defined $H)) { if (&parse_tz_only(\$t, \$tz, \$tzo)) { $parse .= " ".__LINE__ if $debug; next; } } if (! defined $H and ! defined $rs) { if (&parse_time_offset(\$t, \$rs, %options)) { $rel = 1; $parse .= " ".__LINE__ if $debug; next; } } if (! defined $m and ! defined $rd and ! defined $y) { if (&parse_date_offset(\$t, $now, \$y, \$m, \$d, \$rd, \$rs, %options)) { $rel = 1; $parse .= " ".__LINE__ if $debug; next; } } if (defined $M or defined $rd) { if ($t =~ s/^\s*(?:at|\@|\+)($break)//x) { $rel = 1; $parse .= " ".__LINE__ if $debug; next; } } last; } continue { $passes++; &debug_display($tz, $tzo, $H, $M, $S, $m, $d, $y, $rs, $rd, $rel, $passes, $parse, $t) if $debug; } if ($passes == 0) { print "nothing matched\n" if $debug; return (undef, "no match on time/date") if wantarray(); return undef; } } &debug_display($tz, $tzo, $H, $M, $S, $m, $d, $y, $rs, $rd, $rel, $passes, $parse, $t) if $debug; $t =~ s/^\s+//; if ($t ne '') { # we didn't manage to eat the string print "NOT WHOLE\n" if $debug; if ($options{WHOLE}) { return (undef, "characters left over after parse") if wantarray(); return undef } } # define a date if there isn't one already if (! defined $y and ! defined $m and ! defined $rd) { print "no date defined, trying to find one." if $debug; if (defined $rs or defined $H) { # we do have a time. if ($options{DATE_REQUIRED}) { return (undef, "no date specified") if wantarray(); return undef; } if (defined $rs) { print "simple offset: $rs\n" if $debug; my $rv = $now + $rs; return ($rv, $t) if wantarray(); return $rv; } $rd = 0; } else { print "no time either!\n" if $debug; return (undef, "no time specified") if wantarray(); return undef; } } if ($options{TIME_REQUIRED} && ! defined($rs) && ! defined($H) && ! defined($rd)) { return (undef, "no time found") if wantarray(); return undef; } my $secs; my $jd; if (defined $rd) { if (defined $rs || ! (defined($H) || defined($M) || defined($S))) { print "fully relative\n" if $debug; my ($j, $in, $it); my $definedrs = defined($rs) ? $rs : 0; my ($isdst_now, $isdst_then); my $r = $now + $rd * 86400 + $definedrs; # # It's possible that there was a timezone shift # during the time specified. If so, keep the # hours the "same". # $isdst_now = (localtime($r))[8]; $isdst_then = (localtime($now))[8]; if (($isdst_now == $isdst_then) || $options{GMT}) { return ($r, $t) if wantarray(); return $r } print "localtime changed DST during time period!\n" if $debug; } print "relative date\n" if $debug; $jd = $options{GMT} ? gm_julian_day($now) : local_julian_day($now); print "jd($now) = $jd\n" if $debug; $jd += $rd; } else { unless (defined $y) { if ($options{PREFER_PAST}) { my ($day, $mon011); ($day, $mon011, $y) = (&righttime($now))[3,4,5]; print "calc year -past $day-$d $mon011-$m $y\n" if $debug; $y -= 1 if ($mon011+1 < $m) || (($mon011+1 == $m) && ($day < $d)); } elsif ($options{PREFER_FUTURE}) { print "calc year -future\n" if $debug; my ($day, $mon011); ($day, $mon011, $y) = (&righttime($now))[3,4,5]; $y += 1 if ($mon011 >= $m) || (($mon011+1 == $m) && ($day > $d)); } else { print "calc year -this\n" if $debug; $y = (localtime($now))[5]; } $y += 1900; } $y = expand_two_digit_year($y, $now, %options) if $y < 100; if ($options{VALIDATE}) { require Time::DaysInMonth; my $dim = Time::DaysInMonth::days_in($y, $m); if ($y < 1000 or $m < 1 or $d < 1 or $y > 9999 or $m > 12 or $d > $dim) { return (undef, "illegal YMD: $y, $m, $d") if wantarray(); return undef; } } $jd = julian_day($y, $m, $d); print "jd($y, $m, $d) = $jd\n" if $debug; } # put time into HMS if (! defined($H)) { if (defined($rd) || defined($rs)) { ($S, $M, $H) = &righttime($now, %options); print "HMS set to $H $M $S\n" if $debug; } } my $carry; print "before ", (defined($rs) ? "$rs" : ""), " $jd $H $M $S\n" if $debug; # # add in relative seconds. Do it this way because we want to # preserve the localtime across DST changes. # $S = 0 unless $S; # -w $M = 0 unless $M; # -w $H = 0 unless $H; # -w if ($options{VALIDATE} and ($S < 0 or $M < 0 or $H < 0 or $S > 59 or $M > 59 or $H > 23)) { return (undef, "illegal HMS: $H, $M, $S") if wantarray(); return undef; } $S += $rs if defined $rs; $carry = int($S / 60) - ($S < 0 && $S % 60 && 1); $S -= $carry * 60; $M += $carry; $carry = int($M / 60) - ($M < 0 && $M % 60 && 1); $M %= 60; $H += $carry; $carry = int($H / 24) - ($H < 0 && $H % 24 && 1); $H %= 24; $jd += $carry; print "after rs $jd $H $M $S\n" if $debug; $secs = jd_secondsgm($jd, $H, $M, $S); print "jd_secondsgm($jd, $H, $M, $S) = $secs\n" if $debug; # # If we see something link 3pm CST then and we want to end # up with a GMT seconds, then we convert the 3pm to GMT and # subtract in the offset for CST. We subtract because we # are converting from CST to GMT. # my $tzadj; if ($tz) { $tzadj = tz_offset($tz, $secs); if (defined $tzadj) { print "adjusting secs for $tz: $tzadj\n" if $debug; $tzadj = tz_offset($tz, $secs-$tzadj); $secs -= $tzadj; } else { print "unknown timezone: $tz\n" if $debug; undef $secs; undef $t; } } elsif (defined $tzo) { print "adjusting time for offset: $tzo\n" if $debug; $secs -= $tzo; } else { unless ($options{GMT}) { if ($options{ZONE}) { $tzadj = tz_offset($options{ZONE}, $secs) || 0; $tzadj = tz_offset($options{ZONE}, $secs-$tzadj); unless (defined($tzadj)) { return (undef, "could not convert '$options{ZONE}' to time offset") if wantarray(); return undef; } print "adjusting secs for $options{ZONE}: $tzadj\n" if $debug; $secs -= $tzadj; } else { $tzadj = tz_local_offset($secs); print "adjusting secs for local offset: $tzadj\n" if $debug; # # Just in case we are very close to a time # change... # $tzadj = tz_local_offset($secs-$tzadj); $secs -= $tzadj; } } } print "returning $secs.\n" if $debug; return ($secs, $t) if wantarray(); return $secs; } sub mkoff { my($offset) = @_; if (defined $offset and $offset =~ s#^([-+])(\d\d):?(\d\d)$##) { return ($1 eq '+' ? 3600 * $2 + 60 * $3 : -3600 * $2 + -60 * $3 ); } return undef; } sub parse_tz_only { my($tr, $tz, $tzo) = @_; $$tr =~ s#^\s+##; my $o; if ($$tr =~ s#^ ([-+]\d\d:?\d\d) \s+ \( "? (?: (?: [A-Z]{1,4}[TCW56] ) | IDLE ) \) $break ##x) { #"emacs $$tzo = &mkoff($1); printf "matched at %d.\n", __LINE__ if $debug; return 1; } elsif ($$tr =~ s#^GMT\s*([-+]\d{1,2})($break)##x) { $o = $1; if ($o < 24 and $o !~ /^0/) { # probably hours. printf "adjusted at %d. ($o 00)\n", __LINE__ if $debug; $o = "${o}00"; } $o =~ s/\b(\d\d\d)/0$1/; $$tzo = &mkoff($o); printf "matched at %d. ($$tzo, $o)\n", __LINE__ if $debug; return 1; } elsif ($$tr =~ s#^(?:GMT\s*)?([-+]\d\d:?\d\d)($break)##x) { $o = $1; $$tzo = &mkoff($o); printf "matched at %d.\n", __LINE__ if $debug; return 1; } elsif ($$tr =~ s#^"?((?:[A-Z]{1,4}[TCW56])|IDLE)$break##x) { #" $$tz = $1; $$tz .= " DST" if $$tz eq 'MET' && $$tr =~ s#^DST$break##x; printf "matched at %d: '$$tz'.\n", __LINE__ if $debug; return 1; } return 0; } sub parse_date_only { my ($tr, $yr, $mr, $dr, $uk) = @_; $$tr =~ s#^\s+##; if ($$tr =~ s#^(\d\d\d\d)([-./])(\d\d?)\2(\d\d?)(T|$break)##) { # yyyy/mm/dd ($$yr, $$mr, $$dr) = ($1, $3, $4); printf "matched at %d.\n", __LINE__ if $debug; return 1; } elsif ($$tr =~ s#^(\d\d?)([-./])(\d\d?)\2(\d\d\d\d?)($break)##) { # mm/dd/yyyy - is this safe? No. # -- or dd/mm/yyyy! If $1>12, then it's unambiguous. # Otherwise check option UK for UK style date. if ($uk || $1>12) { ($$yr, $$mr, $$dr) = ($4, $3, $1); } else { ($$yr, $$mr, $$dr) = ($4, $1, $3); } printf "matched at %d.\n", __LINE__ if $debug; return 1; } elsif ($$tr =~ s#^(\d\d\d\d)/(\d\d?)$break##x) { # yyyy/mm ($$yr, $$mr, $$dr) = ($1, $2, 1); printf "matched at %d.\n", __LINE__ if $debug; return 1; } elsif ($$tr =~ s#^(?xi) (?: (?:Mon|Monday|Tue|Tuesday|Wed|Wednesday| Thu|Thursday|Fri|Friday| Sat|Saturday|Sun|Sunday),? \s+ )? (\d\d?) (\s+ | - | \. | /) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\.? (?: \2 (\d\d (?:\d\d)? ) )? $break ##) { # [Dow,] dd Mon [yy[yy]] ($$yr, $$mr, $$dr) = ($4, $mtable{"\u\L$3"}, $1); printf "%d: %s - %s - %s\n", __LINE__, $1, $2, $3 if $debug; print "y undef\n" if ($debug && ! defined($$yr)); return 1; } elsif ($$tr =~ s#^(?xi) (?: (?:Mon|Monday|Tue|Tuesday|Wed|Wednesday| Thu|Thursday|Fri|Friday| Sat|Saturday|Sun|Sunday),? \s+ )? (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\.? ((\s)+ | - | \. | /) (\d\d?) ,? (?: (?: \2|\3+) (\d\d (?: \d\d)?) )? $break ##) { # [Dow,] Mon dd [yyyy] # [Dow,] Mon d, [yy] ($$yr, $$mr, $$dr) = ($5, $mtable{"\u\L$1"}, $4); printf "%d: %s - %s - %s\n", __LINE__, $1, $2, $4 if $debug; print "y undef\n" if ($debug && ! defined($$yr)); return 1; } elsif ($$tr =~ s#^(?xi) (January|Jan\.?|February|Feb\.?|March|Mar\.?|April|Apr\.?|May| June|Jun\.?|July|Jul\.?|August|Aug\.?|September|Sep\.?| October|Oct\.?|November|Nov\.?|December|Dec\.?) \s+ (\d+) (?:st|nd|rd|th)? \,? (?: \s+ (?: (\d\d\d\d) |(?:\' (\d\d)) ) )? $break ##) { # Month day{st,nd,rd,th}, 'yy # Month day{st,nd,rd,th}, year # Month day, year # Mon. day, year ($$yr, $$mr, $$dr) = ($3 || $4, $mtable{"\u\L$1"}, $2); printf "%d: %s - %s - %s - %s\n", __LINE__, $1, $2, $3, $4 if $debug; print "y undef\n" if ($debug && ! defined($$yr)); printf "matched at %d.\n", __LINE__ if $debug; return 1; } elsif ($$tr =~ s#^(\d\d?)([-/.])(\d\d?)\2(\d\d?)($break)##x) { if ($1 > 31 || (!$uk && $1 > 12 && $4 < 32)) { # yy/mm/dd ($$yr, $$mr, $$dr) = ($1, $3, $4); } elsif ($1 > 12 || $uk) { # dd/mm/yy ($$yr, $$mr, $$dr) = ($4, $3, $1); } else { # mm/dd/yy ($$yr, $$mr, $$dr) = ($4, $1, $3); } printf "matched at %d.\n", __LINE__ if $debug; return 1; } elsif ($$tr =~ s#^(\d\d?)/(\d\d?)($break)##x) { if ($1 > 31 || (!$uk && $1 > 12)) { # yy/mm ($$yr, $$mr, $$dr) = ($1, $2, 1); } elsif ($2 > 31 || ($uk && $2 > 12)) { # mm/yy ($$yr, $$mr, $$dr) = ($2, $1, 1); } elsif ($1 > 12 || $uk) { # dd/mm ($$mr, $$dr) = ($2, $1); } else { # mm/dd ($$mr, $$dr) = ($1, $2); } printf "matched at %d.\n", __LINE__ if $debug; return 1; } elsif ($$tr =~ s#^(\d\d)(\d\d)(\d\d)($break)##x) { if ($1 > 31 || (!$uk && $1 > 12)) { # YYMMDD ($$yr, $$mr, $$dr) = ($1, $2, $3); } elsif ($1 > 12 || $uk) { # DDMMYY ($$yr, $$mr, $$dr) = ($3, $2, $1); } else { # MMDDYY ($$yr, $$mr, $$dr) = ($3, $1, $2); } printf "matched at %d.\n", __LINE__ if $debug; return 1; } elsif ($$tr =~ s#^(?xi) (\d{1,2}) (\s+ | - | \. | /) (January|Jan\.?|February|Feb\.?|March|Mar\.?|April|Apr\.?|May| June|Jun\.?|July|Jul\.?|August|Aug\.?|September|Sep\.?| October|Oct\.?|November|Nov\.?|December|Dec\.?) (?: \2 ( \d\d (?:\d\d)? ) ) $break ##) { # dd Month [yr] ($$yr, $$mr, $$dr) = ($4, $mtable{"\u\L$3"}, $1); printf "matched at %d.\n", __LINE__ if $debug; return 1; } elsif ($$tr =~ s#^(?xi) (\d+) (?:st|nd|rd|th)? \s+ (January|Jan\.?|February|Feb\.?|March|Mar\.?|April|Apr\.?|May| June|Jun\.?|July|Jul\.?|August|Aug\.?|September|Sep\.?| October|Oct\.?|November|Nov\.?|December|Dec\.?) (?: \,? \s+ (\d\d\d\d) )? $break ##) { # day{st,nd,rd,th}, Month year ($$yr, $$mr, $$dr) = ($3, $mtable{"\u\L$2"}, $1); printf "%d: %s - %s - %s - %s\n", __LINE__, $1, $2, $3, $4 if $debug; print "y undef\n" if ($debug && ! defined($$yr)); printf "matched at %d.\n", __LINE__ if $debug; return 1; } return 0; } sub parse_time_only { my ($tr, $hr, $mr, $sr, $tzr, %options) = @_; $$tr =~ s#^\s+##; if ($$tr =~ s/^(?x) (?: (?: ([012]\d) (?# $1) (?: ([0-5]\d) (?# $2) (?: ([0-5]\d) (?# $3) )? ) (?:\s*([apAP][mM]))? (?# $4) ) | (?: (\d{1,2}) (?# $5) (?: \: (\d\d) (?# $6) (?: \: (\d\d) (?# $7) ( (?# don't barf on database sub-second timings) [:.,] \d+ )? (?# $8) )? ) (?:\s*([apAP][mM]))? (?# $9) ) | (?: (\d{1,2}) (?# $10) ([apAP][mM]) (?# ${11}) ) ) (?: (?: \s+ "? ( (?# ${12}) (?: [A-Z]{1,4}[TCW56](?!(?:\+\d+|\s+DST)) ) | IDLE ) ) | ([Zz]) (?# ${13}) )? $break //) { #"emacs # HH[[:]MM[:SS]]meridian [zone] my $ampm; $$hr = $1 || $5 || $10 || 0; # 10 is undef, but 5 is defined.. $$mr = $2 || $6 || 0; $$sr = $3 || $7 || 0; if (defined($8) && exists($options{SUBSECOND}) && $options{SUBSECOND}) { my($frac) = $8; substr($frac,0,1) = '.'; $$sr += $frac; } print "S = $$sr\n" if $debug; $ampm = $4 || $9 || $11 || ''; printf "ampm at %d: %s %s %s\n", __LINE__, $4||'(no)', $9||'(no)', $11||'(no)' if $debug; $$tzr = $12; $$tzr = 'UTC' if defined $13; $$hr += 12 if $ampm and "\U$ampm" eq "PM" && $$hr != 12; $$hr = 0 if $$hr == 12 && "\U$ampm" eq "AM"; printf "matched at %d, rem = %s.\n", __LINE__, $$tr if $debug; return 1; } elsif ($$tr =~ s#^noon$break##ix) { # noon ($$hr, $$mr, $$sr) = (12, 0, 0); printf "matched at %d.\n", __LINE__ if $debug; return 1; } elsif ($$tr =~ s#^midnight$break##ix) { # midnight ($$hr, $$mr, $$sr) = (0, 0, 0); printf "matched at %d.\n", __LINE__ if $debug; return 1; } return 0; } sub parse_time_offset { my ($tr, $rsr, %options) = @_; $$tr =~ s/^\s+//; return 0 if $options{NO_RELATIVE}; if ($$tr =~ s{^(?xi) (?: (-) (?# 1) | [+] )? \s* (?: (\d+(?:\.\d+)?) (?# 2) | (?:(\d+)\s+(\d+)/(\d+)) (?# 3 4/5) ) \s* (sec|second|min|minute|hour)s? (?# 6) ( \s+ ago (?# 7) )? $break }{}) { # count units $$rsr = 0 unless defined $$rsr; return 0 if defined($5) && $5 == 0; my $num = defined($2) ? $2 : $3 + $4/$5; $num = -$num if $1; $$rsr += $umult{"\L$6"} * $num; $$rsr = -$$rsr if $7 || $$tr =~ /\b(day|mon|month|year)s?\s*ago\b/; printf "matched at %d.\n", __LINE__ if $debug; return 1; } return 0; } # # What to you do with a date that has a two-digit year? # There's not much that can be done except make a guess. # # Some example situations to handle: # # now year # # 1999 01 # 1999 71 # 2010 71 # 2110 09 # sub expand_two_digit_year { my ($yr, $now, %options) = @_; return $yr if $yr > 100; my ($y) = (&righttime($now, %options))[5]; $y += 1900; my $century = int($y / 100) * 100; my $within = $y % 100; my $r = $yr + $century; if ($options{PREFER_PAST}) { if ($yr > $within) { $r = $yr + $century - 100; } } elsif ($options{PREFER_FUTURE}) { # being strict here would be silly if ($yr < $within-20) { # it's 2019 and the date is '08' $r = $yr + $century + 100; } } elsif ($options{UNAMBIGUOUS}) { # we really shouldn't guess return undef; } else { # prefer the current century in most cases if ($within > 80 && $within - $yr > 60) { $r = $yr + $century + 100; } if ($within < 30 && $yr - $within > 59) { $r = $yr + $century - 100; } } print "two digit year '$yr' expanded into $r\n" if $debug; return $r; } sub calc { my ($rsr, $yr, $mr, $dr, $rdr, $now, $units, $count, %options) = @_; confess unless $units; $units = "\L$units"; print "calc based on $units\n" if $debug; if ($units eq 'day') { $$rdr = $count; } elsif ($units eq 'week') { $$rdr = $count * 7; } elsif ($umult{$units}) { $$rsr = $count * $umult{$units}; } elsif ($units eq 'mon' || $units eq 'month') { ($$yr, $$mr, $$dr) = &monthoff($now, $count, %options); $$rsr = 0 unless $$rsr; } elsif ($units eq 'year') { ($$yr, $$mr, $$dr) = &monthoff($now, $count * 12, %options); $$rsr = 0 unless $$rsr; } else { carp "interal error"; } print "calced rsr $$rsr rdr $$rdr, yr $$yr mr $$mr dr $$dr.\n" if $debug; } sub monthoff { my ($now, $months, %options) = @_; # months are 0..11 my ($d, $m11, $y) = (&righttime($now, %options)) [ 3,4,5 ] ; $y += 1900; print "m11 = $m11 + $months, y = $y\n" if $debug; $m11 += $months; print "m11 = $m11, y = $y\n" if $debug; if ($m11 > 11 || $m11 < 0) { $y -= 1 if $m11 < 0 && ($m11 % 12 != 0); $y += int($m11/12); # this is required to work around a bug in perl 5.003 no integer; $m11 %= 12; } print "m11 = $m11, y = $y\n" if $debug; # # What is "1 month from January 31st?" # I think the answer is February 28th most years. # # Similarly, what is one year from February 29th, 1980? # I think it's February 28th, 1981. # # If you disagree, change the following code. # if ($d > 30 or ($d > 28 && $m11 == 1)) { require Time::DaysInMonth; my $dim = Time::DaysInMonth::days_in($y, $m11+1); print "dim($y,$m11+1)= $dim\n" if $debug; $d = $dim if $d > $dim; } return ($y, $m11+1, $d); } sub righttime { my ($time, %options) = @_; if ($options{GMT}) { return gmtime($time); } else { return localtime($time); } } sub parse_year_only { my ($tr, $yr, $now, %options) = @_; $$tr =~ s#^\s+##; if ($$tr =~ s#^(\d\d\d\d)$break##) { $$yr = $1; printf "matched at %d.\n", __LINE__ if $debug; return 1; } elsif ($$tr =~ s#\'(\d\d)$break##) { $$yr = expand_two_digit_year($1, $now, %options); printf "matched at %d.\n", __LINE__ if $debug; return 1; } return 0; } sub parse_date_offset { my ($tr, $now, $yr, $mr, $dr, $rdr, $rsr, %options) = @_; return 0 if $options{NO_RELATIVE}; # now - current seconds_since_epoch # yr - year return # mr - month return # dr - day return # rdr - relative day return # rsr - relative second return my $j; my $wday = (&righttime($now, %options))[6]; $$tr =~ s#^\s+##; if ($$tr =~ s#^(?xi) \s* (\d+) \s* (day|week|month|year)s? ( \s+ ago )? $break ##) { my $amt = $1 + 0; my $units = $2; $amt = -$amt if $3 || $$tr =~ m#\b(sec|second|min|minute|hour)s?\s*ago\b#; &calc($rsr, $yr, $mr, $dr, $rdr, $now, $units, $amt, %options); printf "matched at %d.\n", __LINE__ if $debug; return 1; } elsif ($$tr =~ s#^(?xi) (?: (?: now \s+ )? (\+ | \-) \s* )? (\d+) \s* (day|week|month|year)s? $break ##) { my $one = $1 || ''; my $two = $2 || ''; my $amt = "$one$two"+0; &calc($rsr, $yr, $mr, $dr, $rdr, $now, $3, $amt, %options); printf "matched at %d.\n", __LINE__ if $debug; return 1; } elsif ($$tr =~ s#^(?xi) (Mon|Tue|Wed|Thu|Fri|Sat|Sun|Monday|Tuesday |Wednesday|Thursday|Friday|Saturday|Sunday) \s+ after \s+ next $break ##) { # Dow "after next" $$rdr = $wdays{"\L$1"} - $wday + ( $wdays{"\L$1"} > $wday ? 7 : 14); printf "matched at %d.\n", __LINE__ if $debug; return 1; } elsif ($$tr =~ s#^(?xi) (Mon|Tue|Wed|Thu|Fri|Sat|Sun|Monday|Tuesday |Wednesday|Thursday|Friday|Saturday|Sunday) \s+ before \s+ last $break ##) { # Dow "before last" $$rdr = $wdays{"\L$1"} - $wday - ( $wdays{"\L$1"} < $wday ? 7 : 14); printf "matched at %d.\n", __LINE__ if $debug; return 1; } elsif ($$tr =~ s#^(?xi) next\s+ (Mon|Tue|Wed|Thu|Fri|Sat|Sun|Monday|Tuesday |Wednesday|Thursday|Friday|Saturday|Sunday) $break ##) { # "next" Dow $$rdr = $wdays{"\L$1"} - $wday + ( $wdays{"\L$1"} > $wday ? 0 : 7); printf "matched at %d.\n", __LINE__ if $debug; return 1; } elsif ($$tr =~ s#^(?xi) last\s+ (Mon|Tue|Wed|Thu|Fri|Sat|Sun|Monday|Tuesday |Wednesday|Thursday|Friday|Saturday|Sunday) $break##) { # "last" Dow printf "c %d - %d + ( %d < %d ? 0 : -7 \n", $wdays{"\L$1"}, $wday, $wdays{"\L$1"}, $wday if $debug; $$rdr = $wdays{"\L$1"} - $wday + ( $wdays{"\L$1"} < $wday ? 0 : -7); printf "matched at %d.\n", __LINE__ if $debug; return 1; } elsif ($options{PREFER_PAST} and $$tr =~ s#^(?xi) (Mon|Tue|Wed|Thu|Fri|Sat|Sun|Monday|Tuesday |Wednesday|Thursday|Friday|Saturday|Sunday) $break##) { # Dow printf "c %d - %d + ( %d < %d ? 0 : -7 \n", $wdays{"\L$1"}, $wday, $wdays{"\L$1"}, $wday if $debug; $$rdr = $wdays{"\L$1"} - $wday + ( $wdays{"\L$1"} < $wday ? 0 : -7); printf "matched at %d.\n", __LINE__ if $debug; return 1; } elsif ($options{PREFER_FUTURE} and $$tr =~ s#^(?xi) (Mon|Tue|Wed|Thu|Fri|Sat|Sun|Monday|Tuesday |Wednesday|Thursday|Friday|Saturday|Sunday) $break ##) { # Dow $$rdr = $wdays{"\L$1"} - $wday + ( $wdays{"\L$1"} > $wday ? 0 : 7); printf "matched at %d.\n", __LINE__ if $debug; return 1; } elsif ($$tr =~ s#^today$break##xi) { # today $$rdr = 0; printf "matched at %d.\n", __LINE__ if $debug; return 1; } elsif ($$tr =~ s#^tomorrow$break##xi) { $$rdr = 1; printf "matched at %d.\n", __LINE__ if $debug; return 1; } elsif ($$tr =~ s#^yesterday$break##xi) { $$rdr = -1; printf "matched at %d.\n", __LINE__ if $debug; return 1; } elsif ($$tr =~ s#^last\s+(week|month|year)$break##xi) { &calc($rsr, $yr, $mr, $dr, $rdr, $now, $1, -1, %options); printf "matched at %d.\n", __LINE__ if $debug; return 1; } elsif ($$tr =~ s#^next\s+(week|month|year)$break##xi) { &calc($rsr, $yr, $mr, $dr, $rdr, $now, $1, 1, %options); printf "matched at %d.\n", __LINE__ if $debug; return 1; } elsif ($$tr =~ s#^now $break##x) { $$rdr = 0; return 1; } return 0; } sub debug_display { my ($tz, $tzo, $H, $M, $S, $m, $d, $y, $rs, $rd, $rel, $passes, $parse, $t) = @_; print "---------<<\n"; print defined($tz) ? "tz: $tz.\n" : "no tz\n"; print defined($tzo) ? "tzo: $tzo.\n" : "no tzo\n"; print "HMS: "; print defined($H) ? "$H, " : "no H, "; print defined($M) ? "$M, " : "no M, "; print defined($S) ? "$S\n" : "no S.\n"; print "mdy: "; print defined($m) ? "$m, " : "no m, "; print defined($d) ? "$d, " : "no d, "; print defined($y) ? "$y\n" : "no y.\n"; print defined($rs) ? "rs: $rs.\n" : "no rs\n"; print defined($rd) ? "rd: $rd.\n" : "no rd\n"; print $rel ? "relative\n" : "not relative\n"; print "passes: $passes\n"; print "parse:$parse\n"; print "t: $t.\n"; print "--------->>\n"; } 1; __END__ =head1 NAME Time::ParseDate -- date parsing both relative and absolute =head1 SYNOPSIS use Time::ParseDate; $seconds_since_jan1_1970 = parsedate("12/11/94 2pm", NO_RELATIVE => 1) $seconds_since_jan1_1970 = parsedate("12/11/94 2pm", %options) =head1 OPTIONS Date parsing can also use options. The options are as follows: FUZZY -> it's okay not to parse the entire date string NOW -> the "current" time for relative times (defaults to time()) ZONE -> local timezone (defaults to $ENV{TZ}) WHOLE -> the whole input string must be parsed GMT -> input time is assumed to be GMT, not localtime UK -> prefer UK style dates (dd/mm over mm/dd) DATE_REQUIRED -> do not default the date TIME_REQUIRED -> do not default the time NO_RELATIVE -> input time is not relative to NOW TIMEFIRST -> try parsing time before date [not default] PREFER_PAST -> when year or day of week is ambiguous, assume past PREFER_FUTURE -> when year or day of week is ambiguous, assume future SUBSECOND -> parse fraction seconds VALIDATE -> only accept normal values for HHMMSS, YYMMDD. Otherwise days like -1 might give the last day of the previous month. =head1 DATE FORMATS RECOGNIZED =head2 Absolute date formats Dow, dd Mon yy Dow, dd Mon yyyy Dow, dd Mon dd Mon yy dd Mon yyyy Month day{st,nd,rd,th}, year Month day{st,nd,rd,th} Mon dd yyyy yyyy/mm/dd yyyy-mm-dd (usually the best date specification syntax) yyyy/mm mm/dd/yy mm/dd/yyyy mm/yy yy/mm (only if year > 12, or > 31 if UK) yy/mm/dd (only if year > 12 and day < 32, or year > 31 if UK) dd/mm/yy (only if UK, or an invalid mm/dd/yy or yy/mm/dd) dd/mm/yyyy (only if UK, or an invalid mm/dd/yyyy) dd/mm (only if UK, or an invalid mm/dd) =head2 Relative date formats: count "days" count "weeks" count "months" count "years" Dow "after next" Dow "before last" Dow (requires PREFER_PAST or PREFER_FUTURE) "next" Dow "tomorrow" "today" "yesterday" "last" dow "last week" "now" "now" "+" count units "now" "-" count units "+" count units "-" count units count units "ago" =head2 Absolute time formats: hh:mm:ss[.ddd] hh:mm hh:mm[AP]M hh[AP]M hhmmss[[AP]M] "noon" "midnight" =head2 Relative time formats: count "minutes" (count can be franctional "1.5" or "1 1/2") count "seconds" count "hours" "+" count units "+" count "-" count units "-" count count units "ago" =head2 Timezone formats: [+-]dddd GMT[+-]d+ [+-]dddd (TZN) TZN =head2 Special formats: [ d]d/Mon/yyyy:hh:mm:ss [[+-]dddd] yy/mm/dd.hh:mm =head1 DESCRIPTION This module recognizes the above date/time formats. Usually a date and a time are specified. There are numerous options for controlling what is recognized and what is not. The return code is always the time in seconds since January 1st, 1970 or undef if it was unable to parse the time. If a timezone is specified it must be after the time. Year specifications can be tacked onto the end of absolute times. If C is called from array context, then it will return two elements. On successful parses, it will return the seconds and what remains of its input string. On unsuccessful parses, it will return C and an error string. =head1 EXAMPLES $seconds = parsedate("Mon Jan 2 04:24:27 1995"); $seconds = parsedate("Tue Apr 4 00:22:12 PDT 1995"); $seconds = parsedate("04.04.95 00:22", ZONE => PDT); $seconds = parsedate("Jan 1 1999 11:23:34.578", SUBSECOND => 1); $seconds = parsedate("122212 950404", ZONE => PDT, TIMEFIRST => 1); $seconds = parsedate("+3 secs", NOW => 796978800); $seconds = parsedate("2 months", NOW => 796720932); $seconds = parsedate("last Tuesday"); $seconds = parsedate("Sunday before last"); ($seconds, $remaining) = parsedate("today is the day"); ($seconds, $error) = parsedate("today is", WHOLE=>1); =head1 AUTHOR Best Practical Solutions, LLC Emodules@bestpractical.comE =head1 ORIGINAL AUTHOR David Muir Sharnoff =head1 BUGS All bugs should be reported via email to L or via the web at L. =head1 LICENSE AND COPYRIGHT Copyright (C) 1996-2010 David Muir Sharnoff. Copyright (C) 2011 Google, Inc. Copyright (C) 2026 Best Practical Solutions, LLC. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Time-ParseDate-2026.0219/lib/Time/JulianDay.pm000644 000765 000024 00000013363 15150357775 021301 0ustar00jbrandtstaff000000 000000 package Time::JulianDay; require 5.008001; use Carp; use Time::Timezone; @ISA = qw(Exporter); @EXPORT = qw(julian_day inverse_julian_day day_of_week jd_secondsgm jd_secondslocal jd_timegm jd_timelocal gm_julian_day local_julian_day ); @EXPORT_OK = qw($brit_jd); use strict; use integer; # constants use vars qw($brit_jd $jd_epoch $jd_epoch_remainder $VERSION); $VERSION = 2026.0219; # calculate the julian day, given $year, $month and $day sub julian_day { my($year, $month, $day) = @_; my($tmp); use Carp; # confess() unless defined $day; $tmp = $day - 32075 + 1461 * ( $year + 4800 - ( 14 - $month ) / 12 )/4 + 367 * ( $month - 2 + ( ( 14 - $month ) / 12 ) * 12 ) / 12 - 3 * ( ( $year + 4900 - ( 14 - $month ) / 12 ) / 100 ) / 4 ; return($tmp); } sub gm_julian_day { my($secs) = @_; my($sec, $min, $hour, $mon, $year, $day, $month); ($sec, $min, $hour, $day, $mon, $year) = gmtime($secs); $month = $mon + 1; $year += 1900; return julian_day($year, $month, $day) } sub local_julian_day { my($secs) = @_; my($sec, $min, $hour, $mon, $year, $day, $month); ($sec, $min, $hour, $day, $mon, $year) = localtime($secs); $month = $mon + 1; $year += 1900; return julian_day($year, $month, $day) } sub day_of_week { my ($jd) = @_; return (($jd + 1) % 7); # calculate weekday (0=Sun,6=Sat) } # The following defines the first day that the Gregorian calendar was used # in the British Empire (Sep 14, 1752). The previous day was Sep 2, 1752 # by the Julian Calendar. The year began at March 25th before this date. $brit_jd = 2361222; # Usage: ($year,$month,$day) = &inverse_julian_day($julian_day) sub inverse_julian_day { my($jd) = @_; my($jdate_tmp); my($m,$d,$y); carp("warning: julian date $jd pre-dates British use of Gregorian calendar\n") if ($jd < $brit_jd); $jdate_tmp = $jd - 1721119; $y = (4 * $jdate_tmp - 1)/146097; $jdate_tmp = 4 * $jdate_tmp - 1 - 146097 * $y; $d = $jdate_tmp/4; $jdate_tmp = (4 * $d + 3)/1461; $d = 4 * $d + 3 - 1461 * $jdate_tmp; $d = ($d + 4)/4; $m = (5 * $d - 3)/153; $d = 5 * $d - 3 - 153 * $m; $d = ($d + 5) / 5; $y = 100 * $y + $jdate_tmp; if($m < 10) { $m += 3; } else { $m -= 9; ++$y; } return ($y, $m, $d); } { my($sec, $min, $hour, $day, $mon, $year) = gmtime(0); $year += 1900; if ($year == 1970 && $mon == 0 && $day == 1) { # standard unix time format $jd_epoch = 2440588; } else { $jd_epoch = julian_day($year, $mon+1, $day); } $jd_epoch_remainder = $hour*3600 + $min*60 + $sec; } sub jd_secondsgm { my($jd, $hr, $min, $sec) = @_; my($r) = (($jd - $jd_epoch) * 86400 + $hr * 3600 + $min * 60 - $jd_epoch_remainder); no integer; return ($r + $sec); use integer; } sub jd_secondslocal { my($jd, $hr, $min, $sec) = @_; my $jds = jd_secondsgm($jd, $hr, $min, $sec); return $jds - tz_local_offset($jds); } # this uses a 0-11 month to correctly reverse localtime() sub jd_timelocal { my ($sec,$min,$hours,$mday,$mon,$year) = @_; $year += 1900 unless $year > 1000; my $jd = julian_day($year, $mon+1, $mday); my $jds = jd_secondsgm($jd, $hours, $min, $sec); return $jds - tz_local_offset($jds); } # this uses a 0-11 month to correctly reverse gmtime() sub jd_timegm { my ($sec,$min,$hours,$mday,$mon,$year) = @_; $year += 1900 unless $year > 1000; my $jd = julian_day($year, $mon+1, $mday); return jd_secondsgm($jd, $hours, $min, $sec); } 1; __END__ =head1 NAME Time::JulianDay -- Julian calendar manipulations =head1 SYNOPSIS use Time::JulianDay $jd = julian_day($year, $month_1_to_12, $day) $jd = local_julian_day($seconds_since_1970); $jd = gm_julian_day($seconds_since_1970); ($year, $month_1_to_12, $day) = inverse_julian_day($jd) $dow = day_of_week($jd) print (Sun,Mon,Tue,Wed,Thu,Fri,Sat)[$dow]; $seconds_since_jan_1_1970 = jd_secondslocal($jd, $hour, $min, $sec) $seconds_since_jan_1_1970 = jd_secondsgm($jd, $hour, $min, $sec) $seconds_since_jan_1_1970 = jd_timelocal($sec,$min,$hours,$mday,$month_0_to_11,$year) $seconds_since_jan_1_1970 = jd_timegm($sec,$min,$hours,$mday,$month_0_to_11,$year) =head1 DESCRIPTION JulianDay is a package that manipulates dates as number of days since some time a long time ago. It's easy to add and subtract time using julian days... The day_of_week returned by day_of_week() is 0 for Sunday, and 6 for Saturday and everything else is in between. =head1 ERRATA Time::JulianDay is not a correct implementation. There are two problems. The first problem is that Time::JulianDay only works with integers. Julian Day can be fractional to represent time within a day. If you call inverse_julian_day() with a non-integer time, it will often give you an incorrect result. The second problem is that Julian Days start at noon rather than midnight. The julian_day() function returns results that are too large by 0.5. What to do about these problems is currently open for debate. I'm tempted to leave the current functions alone and add a second set with more accurate behavior. There is another implementation in Astro::Time that may be more accurate. =head1 AUTHOR Best Practical Solutions, LLC Emodules@bestpractical.comE =head1 ORIGINAL AUTHOR David Muir Sharnoff =head1 GENESIS Based on previous work by Kurt Jaeger, Ian Miller, Gary Puckering (based on Collected Algorithms of the ACM), and the author of Time::Local. =head1 LICENSE AND COPYRIGHT Copyright (C) 1996-1999 David Muir Sharnoff. Copyright (C) 2026 Best Practical Solutions, LLC. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Time-ParseDate-2026.0219/lib/Time/Timezone.pm000644 000765 000024 00000023021 15150357775 021203 0ustar00jbrandtstaff000000 000000 package Time::Timezone; require 5.008001; require Exporter; @ISA = qw(Exporter); @EXPORT = qw(tz2zone tz_local_offset tz_offset tz_name); @EXPORT_OK = qw(); use Carp; use strict; # Parts stolen from code by Paul Foley use vars qw($VERSION); $VERSION = 2026.0219; sub tz2zone { my($TZ, $time, $isdst) = @_; use vars qw(%tzn_cache); $TZ = defined($ENV{'TZ'}) ? ( $ENV{'TZ'} ? $ENV{'TZ'} : 'GMT' ) : '' unless $TZ; # Hack to deal with 'PST8PDT' format of TZ # Note that this can't deal with all the esoteric forms, but it # does recognize the most common: [:]STDoff[DST[off][,rule]] if (! defined $isdst) { my $j; $time = time() unless defined $time; ($j, $j, $j, $j, $j, $j, $j, $j, $isdst) = localtime($time); } if (defined $tzn_cache{$TZ}->[$isdst]) { return $tzn_cache{$TZ}->[$isdst]; } if ($TZ =~ /^ ( [^:\d+\-,] {3,} ) ( [+-] ? \d {1,2} ( : \d {1,2} ) {0,2} ) ( [^\d+\-,] {3,} )? /x ) { $TZ = $isdst ? $4 : $1; $tzn_cache{$TZ} = [ $1, $4 ]; } else { $tzn_cache{$TZ} = [ $TZ, $TZ ]; } return $TZ; } sub tz_local_offset { my ($time) = @_; $time = time() unless defined $time; return &calc_off($time); } sub calc_off { my ($time) = @_; my (@l) = localtime($time); my (@g) = gmtime($time); my $off; $off = $l[0] - $g[0] + ($l[1] - $g[1]) * 60 + ($l[2] - $g[2]) * 3600; # subscript 7 is yday. if ($l[7] == $g[7]) { # done } elsif ($l[7] == $g[7] + 1) { $off += 86400; } elsif ($l[7] == $g[7] - 1) { $off -= 86400; } elsif ($l[7] < $g[7]) { # crossed over a year boundary! # localtime is beginning of year, gmt is end # therefore local is ahead $off += 86400; } else { $off -= 86400; } return $off; } # constants # The rest of the file originally comes from Graham Barr # # Some references: # http://www.weltzeituhr.com/laender/zeitzonen_e.shtml # http://www.worldtimezone.com/wtz-names/timezonenames.html # http://www.timegenie.com/timezones.php CONFIG: { use vars qw(%dstZone %zoneOff %dstZoneOff %Zone); %dstZone = ( "brst" => -2*3600, # Brazil Summer Time (East Daylight) "adt" => -3*3600, # Atlantic Daylight "edt" => -4*3600, # Eastern Daylight "cdt" => -5*3600, # Central Daylight "mdt" => -6*3600, # Mountain Daylight "pdt" => -7*3600, # Pacific Daylight "ydt" => -8*3600, # Yukon Daylight "hdt" => -9*3600, # Hawaii Daylight "bst" => +1*3600, # British Summer "mest" => +2*3600, # Middle European Summer "met dst" => +2*3600, # Middle European Summer "sst" => +2*3600, # Swedish Summer "fst" => +2*3600, # French Summer "eest" => +3*3600, # Eastern European Summer "cest" => +2*3600, # Central European Daylight "wadt" => +8*3600, # West Australian Daylight "kdt" => +10*3600, # Korean Daylight # "cadt" => +10*3600+1800, # Central Australian Daylight "eadt" => +11*3600, # Eastern Australian Daylight "nzdt" => +13*3600, # New Zealand Daylight ); # not included due to ambiguity: # IST Indian Standard Time +5.5 # Ireland Standard Time 0 # Israel Standard Time +2 # IDT Ireland Daylight Time +1 # Israel Daylight Time +3 # AMST Amazon Standard Time / -3 # Armenia Standard Time +8 # BST Brazil Standard -3 %Zone = ( "gmt" => 0, # Greenwich Mean "ut" => 0, # Universal (Coordinated) "utc" => 0, "wet" => 0, # Western European "wat" => -1*3600, # West Africa "azost" => -1*3600, # Azores Standard Time "cvt" => -1*3600, # Cape Verde Time "at" => -2*3600, # Azores "fnt" => -2*3600, # Brazil Time (Extreme East - Fernando Noronha) "ndt" => -2*3600-1800,# Newfoundland Daylight "art" => -3*3600, # Argentina Time # For completeness. BST is also British Summer, and GST is also Guam Standard. # "gst" => -3*3600, # Greenland Standard "nft" => -3*3600-1800,# Newfoundland # "nst" => -3*3600-1800,# Newfoundland Standard "mnt" => -4*3600, # Brazil Time (West Standard - Manaus) "ewt" => -4*3600, # U.S. Eastern War Time "ast" => -4*3600, # Atlantic Standard "bot" => -4*3600, # Bolivia Time "vet" => -4*3600, # Venezuela Time "est" => -5*3600, # Eastern Standard "cot" => -5*3600, # Colombia Time "act" => -5*3600, # Brazil Time (Extreme West - Acre) "pet" => -5*3600, # Peru Time "cst" => -6*3600, # Central Standard "cest" => +2*3600, # Central European Summer "mst" => -7*3600, # Mountain Standard "pst" => -8*3600, # Pacific Standard "yst" => -9*3600, # Yukon Standard "hst" => -10*3600, # Hawaii Standard "cat" => -10*3600, # Central Alaska "ahst" => -10*3600, # Alaska-Hawaii Standard "taht" => -10*3600, # Tahiti Time "nt" => -11*3600, # Nome "idlw" => -12*3600, # International Date Line West "cet" => +1*3600, # Central European "mez" => +1*3600, # Central European (German) "met" => +1*3600, # Middle European "mewt" => +1*3600, # Middle European Winter "swt" => +1*3600, # Swedish Winter "set" => +1*3600, # Seychelles "fwt" => +1*3600, # French Winter "west" => +1*3600, # Western Europe Summer Time "eet" => +2*3600, # Eastern Europe, USSR Zone 1 "ukr" => +2*3600, # Ukraine "sast" => +2*3600, # South Africa Standard Time "bt" => +3*3600, # Baghdad, USSR Zone 2 "eat" => +3*3600, # East Africa Time # "it" => +3*3600+1800,# Iran "irst" => +3*3600+1800,# Iran Standard Time "zp4" => +4*3600, # USSR Zone 3 "msd" => +4*3600, # Moscow Daylight Time "sct" => +4*3600, # Seychelles Time "zp5" => +5*3600, # USSR Zone 4 "azst" => +5*3600, # Azerbaijan Summer Time "mvt" => +5*3600, # Maldives Time "uzt" => +5*3600, # Uzbekistan Time "ist" => +5*3600+1800,# Indian Standard "zp6" => +6*3600, # USSR Zone 5 "lkt" => +6*3600, # Sri Lanka Time "pkst" => +6*3600, # Pakistan Summer Time "yekst" => +6*3600, # Yekaterinburg Summer Time # For completeness. NST is also Newfoundland Stanard, and SST is also Swedish Summer. # "nst" => +6*3600+1800,# North Sumatra # "sst" => +7*3600, # South Sumatra, USSR Zone 6 "wast" => +7*3600, # West Australian Standard "ict" => +7*3600, # Indochina Time "wit" => +7*3600, # Western Indonesia Time # "jt" => +7*3600+1800,# Java (3pm in Cronusland!) "cct" => +8*3600, # China Coast, USSR Zone 7 "wst" => +8*3600, # West Australian Standard "hkt" => +8*3600, # Hong Kong "bnt" => +8*3600, # Brunei Darussalam Time "cit" => +8*3600, # Central Indonesia Time "myt" => +8*3600, # Malaysia Time "pht" => +8*3600, # Philippines Time "sgt" => +8*3600, # Singapore Time "jst" => +9*3600, # Japan Standard, USSR Zone 8 "kst" => +9*3600, # Korean Standard # "cast" => +9*3600+1800,# Central Australian Standard "east" => +10*3600, # Eastern Australian Standard "gst" => +10*3600, # Guam Standard, USSR Zone 9 "nct" => +11*3600, # New Caledonia Time "nzt" => +12*3600, # New Zealand "nzst" => +12*3600, # New Zealand Standard "fjt" => +12*3600, # Fiji Time "idle" => +12*3600, # International Date Line East ); %zoneOff = reverse(%Zone); %dstZoneOff = reverse(%dstZone); # Preferences $zoneOff{0} = 'gmt'; $dstZoneOff{3600} = 'bst'; } sub tz_offset { my ($zone, $time) = @_; return &tz_local_offset() unless($zone); $time = time() unless defined $time; my(@l) = localtime($time); my $dst = $l[8]; $zone = lc $zone; if ($zone =~ /^([\-\+]\d{3,4})$/) { my $sign = $1 < 0 ? -1 : 1 ; my $v = abs(0 + $1); return $sign * 60 * (int($v / 100) * 60 + ($v % 100)); } elsif (exists $dstZone{$zone} && ($dst || !exists $Zone{$zone})) { return $dstZone{$zone}; } elsif(exists $Zone{$zone}) { return $Zone{$zone}; } undef; } sub tz_name { my ($off, $time) = @_; $time = time() unless defined $time; my(@l) = localtime($time); my $dst = $l[8]; if (exists $dstZoneOff{$off} && ($dst || !exists $zoneOff{$off})) { return $dstZoneOff{$off}; } elsif (exists $zoneOff{$off}) { return $zoneOff{$off}; } sprintf("%+05d", int($off / 60) * 100 + $off % 60); } 1; __END__ =head1 NAME Time::Timezone -- miscellaneous timezone manipulations routines =head1 SYNOPSIS use Time::Timezone; print tz2zone(); print tz2zone($ENV{'TZ'}); print tz2zone($ENV{'TZ'}, time()); print tz2zone($ENV{'TZ'}, undef, $isdst); $offset = tz_local_offset(); $offset = tz_offset($TZ); =head1 DESCRIPTION This is a collection of miscellaneous timezone manipulation routines. C parses the TZ environment variable and returns a timezone string suitable for inclusion in L-like output. It optionally takes a timezone string, a time, and a is-dst flag. C determines the offset from GMT time in seconds. It only does the calculation once. C determines the offset from GMT in seconds of a specified timezone. C determines the name of the timezone based on its offset =head1 AUTHOR Best Practical Solutions, LLC Emodules@bestpractical.comE =head1 ORIGINAL AUTHORS Graham Barr, David Muir Sharnoff, Paul Foley =head1 LICENSE AND COPYRIGHT Copyright (C) 2026 Best Practical Solutions, LLC. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Time-ParseDate-2026.0219/lib/Time/DaysInMonth.pm000644 000765 000024 00000002631 15150357775 021612 0ustar00jbrandtstaff000000 000000 package Time::DaysInMonth; use Carp; require 5.008001; @ISA = qw(Exporter); @EXPORT = qw(days_in is_leap); @EXPORT_OK = qw(%mltable); use strict; use vars qw($VERSION %mltable); $VERSION = 2026.0219; CONFIG: { %mltable = qw( 1 31 3 31 4 30 5 31 6 30 7 31 8 31 9 30 10 31 11 30 12 31); } sub days_in { # Month is 1..12 my ($year, $month) = @_; return $mltable{$month+0} unless $month == 2; return 28 unless &is_leap($year); return 29; } sub is_leap { my ($year) = @_; return 0 unless $year % 4 == 0; return 1 unless $year % 100 == 0; return 0 unless $year % 400 == 0; return 1; } 1; __END__ =head1 NAME Time::DaysInMonth -- simply report the number of days in a month =head1 SYNOPSIS use Time::DaysInMonth; $days = days_in($year, $month_1_to_12); $leapyear = is_leap($year); =head1 DESCRIPTION DaysInMonth is simply a package to report the number of days in a month. That's all it does. Really! =head1 AUTHOR Best Practical Solutions, LLC Emodules@bestpractical.comE =head1 ORIGINAL AUTHOR David Muir Sharnoff =head1 BUGS This only deals with the "modern" calendar. Look elsewhere for historical time and date support. =head1 LICENSE AND COPYRIGHT Copyright (C) 1996-1999 David Muir Sharnoff. Copyright (C) 2026 Best Practical Solutions, LLC. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Time-ParseDate-2026.0219/lib/Time/CTime.pm000644 000765 000024 00000013337 15150357775 020423 0ustar00jbrandtstaff000000 000000 package Time::CTime; require 5.008001; use Time::Timezone; use Time::CTime; require Exporter; @ISA = qw(Exporter); @EXPORT = qw(ctime asctime strftime); @EXPORT_OK = qw(asctime_n ctime_n @DoW @MoY @DayOfWeek @MonthOfYear); use strict; # constants use vars qw(@DoW @DayOfWeek @MoY @MonthOfYear %strftime_conversion $VERSION); use vars qw($template $sec $min $hour $mday $mon $year $wday $yday $isdst); $VERSION = 2026.0219; CONFIG: { @DoW = qw(Sun Mon Tue Wed Thu Fri Sat); @DayOfWeek = qw(Sunday Monday Tuesday Wednesday Thursday Friday Saturday); @MoY = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); @MonthOfYear = qw(January February March April May June July August September October November December); %strftime_conversion = ( '%', sub { '%' }, 'a', sub { $DoW[$wday] }, 'A', sub { $DayOfWeek[$wday] }, 'b', sub { $MoY[$mon] }, 'B', sub { $MonthOfYear[$mon] }, 'c', sub { asctime_n($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst, "") }, 'd', sub { sprintf("%02d", $mday); }, 'D', sub { sprintf("%02d/%02d/%02d", $mon+1, $mday, $year%100) }, 'e', sub { sprintf("%2d", $mday); }, 'f', sub { fracprintf ("%3.3f", $sec); }, 'F', sub { fracprintf ("%6.6f", $sec); }, 'h', sub { $MoY[$mon] }, 'H', sub { sprintf("%02d", $hour) }, 'I', sub { sprintf("%02d", $hour % 12 || 12) }, 'j', sub { sprintf("%03d", $yday + 1) }, 'k', sub { sprintf("%2d", $hour); }, 'l', sub { sprintf("%2d", $hour % 12 || 12) }, 'm', sub { sprintf("%02d", $mon+1); }, 'M', sub { sprintf("%02d", $min) }, 'n', sub { "\n" }, 'o', sub { sprintf("%d%s", $mday, (($mday < 20 && $mday > 3) ? 'th' : ($mday%10 == 1 ? "st" : ($mday%10 == 2 ? "nd" : ($mday%10 == 3 ? "rd" : "th"))))) }, 'p', sub { $hour > 11 ? "PM" : "AM" }, 'r', sub { sprintf("%02d:%02d:%02d %s", $hour % 12 || 12, $min, $sec, $hour > 11 ? 'PM' : 'AM') }, 'R', sub { sprintf("%02d:%02d", $hour, $min) }, 'S', sub { sprintf("%02d", $sec) }, 't', sub { "\t" }, 'T', sub { sprintf("%02d:%02d:%02d", $hour, $min, $sec) }, 'U', sub { wkyr(0, $wday, $yday) }, 'v', sub { sprintf("%2d-%s-%4d", $mday, $MoY[$mon], $year+1900) }, 'w', sub { $wday }, 'W', sub { wkyr(1, $wday, $yday) }, 'y', sub { sprintf("%02d",$year%100) }, 'Y', sub { $year + 1900 }, 'x', sub { sprintf("%02d/%02d/%02d", $mon + 1, $mday, $year%100) }, 'X', sub { sprintf("%02d:%02d:%02d", $hour, $min, $sec) }, 'Z', sub { &tz2zone(undef,undef,$isdst) } # z sprintf("%+03d%02d", $offset / 3600, ($offset % 3600)/60); ); } sub fracprintf { my($t,$s) = @_; my($p) = sprintf($t, $s-int($s)); $p=~s/^0+//; $p; } sub asctime_n { my($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst, $TZname) = @_; ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst, $TZname) = localtime($sec) unless defined $min; $year += 1900; $TZname .= ' ' if $TZname; sprintf("%s %s %2d %2d:%02d:%02d %s%4d", $DoW[$wday], $MoY[$mon], $mday, $hour, $min, $sec, $TZname, $year); } sub asctime { return asctime_n(@_)."\n"; } # is this formula right? sub wkyr { my($wstart, $wday, $yday) = @_; $wday = ($wday + 7 - $wstart) % 7; return int(($yday - $wday + 13) / 7 - 1); } # ctime($time) sub ctime { my($time) = @_; asctime(localtime($time), &tz2zone(undef,$time)); } sub ctime_n { my($time) = @_; asctime_n(localtime($time), &tz2zone(undef,$time)); } # strftime($template, @time_struct) # # Does not support locales sub strftime { local ($template, $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = @_; undef $@; $template =~ s/%([%aAbBcdDefFhHIjklmMnopQrRStTUvwWxXyYZ])/&{$Time::CTime::strftime_conversion{$1}}()/egs; die $@ if $@; return $template; } 1; __END__ =head1 NAME Time::CTime -- format times ala POSIX asctime =head1 SYNOPSIS use Time::CTime print ctime(time); print asctime(localtime(time)); print strftime(template, localtime(time)); =head2 strftime conversions %% PERCENT %a day of the week abbr %A day of the week %b month abbr %B month %c ctime format: Sat Nov 19 21:05:57 1994 %d DD %D MM/DD/YY %e numeric day of the month %f floating point seconds (milliseconds): .314 %F floating point seconds (microseconds): .314159 %h month abbr %H hour, 24 hour clock, leading 0's) %I hour, 12 hour clock, leading 0's) %j day of the year %k hour %l hour, 12 hour clock %m month number, starting with 1, leading 0's %M minute, leading 0's %n NEWLINE %o ornate day of month -- "1st", "2nd", "25th", etc. %p AM or PM %r time format: 09:05:57 PM %R time format: 21:05 %S seconds, leading 0's %t TAB %T time format: 21:05:57 %U week number, Sunday as first day of week %v DD-Mon-Year %w day of the week, numerically, Sunday == 0 %W week number, Monday as first day of week %x date format: 11/19/94 %X time format: 21:05:57 %y year (2 digits) %Y year (4 digits) %Z timezone in ascii. eg: PST =head1 DESCRIPTION This module provides routines to format dates. They correspond to the libc routines. &strftime() supports a pretty good set of conversions -- more than most C libraries. strftime supports a pretty good set of conversions. The POSIX module has very similar functionality. You should consider using it instead if you do not have allergic reactions to system libraries. =head1 AUTHOR Best Practical Solutions, LLC Emodules@bestpractical.comE =head1 ORIGINAL AUTHOR David Muir Sharnoff =head1 GENESIS The starting point for this package was a posting by Paul Foley. =head1 LICENSE AND COPYRIGHT Copyright (C) 1996-2010 David Muir Sharnoff. Copyright (C) 2011 Google, Inc. Copyright (C) 2026 Best Practical Solutions, LLC. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Time-ParseDate-2026.0219/t/order1.t000644 000765 000024 00000001567 15145615731 017237 0ustar00jbrandtstaff000000 000000 #!/usr/bin/perl -I. -w use strict; use warnings; use Test::More; use Time::ParseDate; #use POSIX qw(tzset); use Time::Piece; my $finished; END { ok($finished, 'finished') if defined $finished } $ENV{'LANG'} = 'C'; $ENV{'TZ'} = 'PST8PDT'; my @x = localtime(785307957); my @y = gmtime(785307957); my $hd = $y[2] - $x[2]; $hd += 24 if $hd < 0; $hd %= 24; if ($hd != 8) { plan skip_all => "It seems localtime() does not honor \$ENV{TZ} when set in the test script. Please set the TZ environment variable to PST8PDT and rerun."; exit 0; } plan qw(no_plan); $finished = 0; is(parsedate('1918/2/18'), -1636819200, "year 1918"); is(parsedate('2009/7/7'), 1246950000, "year 2009"); $ENV{'TZ'} = 'Europe/Moscow'; is(parsedate('2009-11-01'), 1257022800, 'Europe/Moscow, DST permanent 2009'); is(parsedate('2013-05-30'), 1369857600, 'Europe/Moscow, DST permanent 2013'); $finished = 1; Time-ParseDate-2026.0219/t/order2.t000644 000765 000024 00000001520 15145615731 017225 0ustar00jbrandtstaff000000 000000 #!/usr/bin/perl -I. -w use strict; use warnings; use Time::ParseDate; use Test::More; my $finished; END { ok($finished, 'finished') if defined $finished } $ENV{'LANG'} = 'C'; $ENV{'TZ'} = 'PST8PDT'; my @x = localtime(785307957); my @y = gmtime(785307957); my $hd = $y[2] - $x[2]; $hd += 24 if $hd < 0; $hd %= 24; if ($hd != 8) { plan skip_all => "It seems localtime() does not honor \$ENV{TZ} when set in the test script. Please set the TZ environment variable to PST8PDT and rerun."; exit 0; } plan qw(no_plan); $finished = 0; is(parsedate('2009/7/7'), 1246950000, "year 2009"); is(parsedate('1918/2/18'), -1636819200, "year 1918"); $ENV{'TZ'} = 'Europe/Moscow'; is(parsedate('2013-05-30'), 1369857600, 'Europe/Moscow, DST permanent 2013'); is(parsedate('2009-11-01'), 1257022800, 'Europe/Moscow, DST permanent 2009'); $finished = 1; Time-ParseDate-2026.0219/t/datetime.t000755 000765 000024 00000047631 15150357775 017653 0ustar00jbrandtstaff000000 000000 #!/usr/bin/perl -I. -w # find out why it died if not running under make $debug = 0; $Time::ParseDate::debug = $debug; BEGIN { $okat = 12; $ENV{'LANG'} = 'C'; $ENV{'TZ'} = 'PST8PDT'; %k = ( '%' => '%', 'a' => 'Sat', 'A' => 'Saturday', 'b' => 'Nov', 'h' => 'Nov', 'B' => 'November', 'c' => "Sat Nov 19 21:05:57 1994", 'd' => '19', 'D' => '11/19/94', 'e' => '19', 'f' => '.500', 'F' => '.500000', 'H' => '21', 'I' => '09', 'j' => '323', 'k' => '21', 'l' => ' 9', 'm' => '11', 'M' => '05', 'n' => "\n", 'o' => '19th', 'p' => "PM", 'r' => "09:05:57 PM", 'R' => "21:05", 'S' => "57", 't' => "\t", 'T' => "21:05:57", 'U' => "46", 'v' => "19-Nov-1994", 'w' => "6", 'W' => "46", 'x' => "11/19/94", 'y' => "94", 'Y' => "1994", 'X' => "21:05:57", 'Z' => "PST" ); $sdt_start_line = __LINE__+2; @sdt = ( 796969332, ['950404 00:22:12 "EDT'], 796969332, ['950404 00:22:12.500 "EDT'], 796969332.5, ['950404 00:22:12.500 "EDT', SUBSECOND => 1], 786437763, ['Fri Dec 2 22:56:03 1994', NOW => 785300000], 786437763, ['Fri Dec 2 22:56:03 1994,', NOW => 785300000, WHOLE => 0], 786408963, ['Fri Dec 2 22:56:03 GMT+0 1994', NOW => 785300000], 786408963, ['Fri Dec 2 22:56:03 GMT+0 1994,', NOW => 785300000, WHOLE => 0], 786408963, ['Fri Dec 2 22:56:03.500 GMT+0 1994', NOW => 785300000], 786408963.5, ['Fri Dec 2 22:56:03.500 GMT+0 1994', SUBSECOND => 1, NOW => 785300000], 786437763, ['Fri Dec 2 22:56:03 GMT-8 1994', NOW => 785300000], 786437763, ['Fri Dec 2 22:56:03 GMT-8 1994, stuff', NOW => 785300000, WHOLE => 0], 786437760, ['94/12/02.22:56', NOW => 785300000], 786437760, ['1994/12/02 10:56Pm', NOW => 785300000], 786437760, ['1994/12/2 10:56 PM', NOW => 785300000], 786437760, ['12/02/94 22:56', NOW => 785300000], 786437760, ['12/02/94 22:56.', NOW => 785300000, WHOLE => 0], 786437760, ['12/2/94 10:56Pm', NOW => 785300000], 786437760, ['94/12/2 10:56 pm', NOW => 785300000], 786437763, ['94/12/02 22:56:03', NOW => 785300000], 786437763, ['94/12/02 22:56:03.500', NOW => 785300000], 786437763.5, ['94/12/02 22:56:03.500', SUBSECOND => 1, NOW => 785300000], 786437763, ['94/12/02 10:56:03:500PM', NOW => 785300000], 786437763.5, ['94/12/02 10:56:03:500PM', SUBSECOND => 1, NOW => 785300000], 786437760, ['10:56Pm 94/12/02', NOW => 785300000], 786437763, ['22:56:03 1994/12/02', NOW => 785300000], 786437763, ['22:56:03.5 1994/12/02', NOW => 785300000], 786437763.5, ['22:56:03.5 1994/12/02', SUBSECOND => 1, NOW => 785300000], 786437760, ['22:56 1994/12/2', NOW => 785300000], 786437760, ['10:56PM 12/02/94', NOW => 785300000], 786437760, ['10:56 pm 12/2/94', NOW => 785300000], # 786437760, ['10:56 pm 12/2/94, when', NOW => 785300000, WHOLE => 0], 786437760, ['22:56 94/12/2', NOW => 785300000], 786437760, ['10:56Pm 94/12/02', NOW => 785300000], 796980132, ['Tue Apr 4 00:22:12 PDT 1995'], 796980132, ['April 4th 1995 12:22:12AM', ZONE => PDT], 827878812, ['Tue Mar 26 14:20:12 1996'], 827878812, ['Tue Mar 26 14:20:12 1996', SUBSECOND => 1], 827878812, ['Tue Mar 26 14:20:12.5 1996, and then', WHOLE => 0], 827878812.5, ['Tue Mar 26 14:20:12.5 1996', SUBSECOND => 1], 827878812, ['Tue Mar 26 14:20:12 GMT-0800 1996'], 827878812, ['Tue Mar 26 17:20:12 EST 1996'], 827878812, ['Tue Mar 26 17:20:12 EST 1996, before Joe', WHOLE => 0], 827878812, ['Tue Mar 26 17:20:12 GMT-0500 1996'], 827878812, ['Tue Mar 26 22:20:12 GMT 1996'], 827878812, ['Tue Mar 26 22:20:12 +0000 (GMT) 1996'], 827878812, ['Tue, 26 Mar 22:20:12 +0000 (GMT) 1996'], 784394917, ['Wed, 9 Nov 1994 7:28:37'], 784394917, ['Wed, 9 Nov 1994 7:28:37: Seven', WHOLE => 0], 784887518, ['Tue, 15 Nov 1994 0:18:38'], 788058300, ['21 dec 17:05', NOW => 785300000], 802940400, ['06/12/1995'], 802940400, ['12/06/1995', UK => 1], 802940400, ['12/06/95', UK => 1], 802940400, ['06.12.1995'], 802940400, ['06.12.1995, Fred', WHOLE => 0], 803026800, ['13/06/1995'], 803026800, ['13/06/95'], 784394917, ['Wed, 9 Nov 1994 15:28:37 +0000 (GMT)'], 827878812, ['Tue Mar 26 23:20:12 GMT+0100 1996'], 827878812, ['Wed Mar 27 05:20:12 GMT+0700 1996'], 827878812, ['Wed Mar 27 05:20:12 +0700 1996'], 827878812, ['Wed Mar 27 05:20:12 +07:00 1996'], 827878812, ['Wed Mar 27 05:20:12 +0700 (EST) 1996'], 796980132, ['1995/04/04 00:22:12 PDT'], 796720932, ['1995/04 00:22:12 PDT'], 796980132, ['1995/04/04 00:22:12 PDT'], 796980132, ['Tue, 4 Apr 95 00:22:12 PDT'], 796980132, ['Tue 4 Apr 1995 00:22:12 PDT'], 796980132, ['04 Apr 1995 00:22:12 PDT'], 796980132, ['4 Apr 1995 00:22:12 PDT'], 796980132, ['Tue, 04 Apr 00:22:12 PDT', NOW => 796980132], 796980132, ['Tue 04 Apr 00:22:12 PDT', NOW => 796980132], 796980132, ['04 Apr 00:22:12 PDT', NOW => 796980132], 796980132, ['Apr 04 00:22:12 PDT', NOW => 796980132], 796980132, ['Apr 4 00:22:12 PDT', NOW => 796980132], 796980132, ['Tue, Apr 4 00:22:12 PDT', NOW => 796980132], 796980132, ['Apr 4 1995 00:22:12 PDT'], 796980132, ['April 4th 1995 00:22:12 PDT'], 796980132, ["April 4th, '95 00:22:12 PDT"], 796980132, ["April 4th 00:22:12 PDT", NOW => 796980132], 796980132, ['95/04/04 00:22:12 PDT'], 796980132, ['04/04/95 00:22:12 PDT'], 796720932, ['95/04 00:22:12 PDT'], 796720932, ['04/95 00:22:12 PDT'], 796980132, ['04/04 00:22:12 PDT', NOW => 796980132], 796980132, ['040495 00:22:12 PDT'], 796980132, ['950404 00:22:12 PDT'], 796969332, ['950404 00:22:12 EDT'], 796980132, ['04.04.95 00:22:12', ZONE => PDT], 796980120, ['04.04.95 00:22', ZONE => PDT], 796978800, ['04.04.95 12AM', ZONE => PDT], 796978800, ['04.04.95 12am', ZONE => PDT], 796980120, ['04.04.95 0022', ZONE => PDT], 796980132, ['04.04.95 12:22:12am', ZONE => PDT], 797023332, ['950404 122212', ZONE => PDT], 797023332, ['122212 950404', ZONE => PDT, TIMEFIRST => 1], 796980120, ['04.04.95 12:22AM', ZONE => PDT], 796978800, ['95/04/04 midnight', ZONE => PDT], 796978800, ['95/04/04 Midnight', ZONE => PDT], 797022000, ['95/04/04 Noon', ZONE => PDT], 797022000, ['95/04/04 noon', ZONE => PDT], 797022000, ['95/04/04 12Pm', ZONE => PDT], 796978803, ['+3 secs', NOW => 796978800], 796979600, ['+0800 seconds', NOW => 796978800], 796979600, ['+0800 seconds, Nothing', NOW => 796978800, WHOLE => 0], 796986000, ['+2 hour', NOW => 796978800], 796979400, ['+10min', NOW => 796978800], 796979400, ['+10 minutes', NOW => 796978800], 797011203, ['95/04/04 +3 secs', ZONE => EDT, NOW => 796935600], 797062935, ['4 day +3 secs', ZONE => PDT, NOW => 796720932], 797062935, ['now + 4 days +3 secs', ZONE => PDT, NOW => 796720932], 797062935, ['now +4 days +3 secs', ZONE => PDT, NOW => 796720932], 796720932, ['now', ZONE => PDT, NOW => 796720932], 796720936, ['now +4 secs', ZONE => PDT, NOW => 796720932], 796735332, ['now +4 hours', ZONE => PDT, NOW => 796720932], 797062935, ['+4 days +3 secs', ZONE => PDT, NOW => 796720932], 797062935, ['+ 4 days +3 secs', ZONE => PDT, NOW => 796720932], 797062929, ['4 day -3 secs', ZONE => PDT, NOW => 796720932], 796375329, ['-4 day -3 secs', ZONE => PDT, NOW => 796720932], 796375329, ['now - 4 days -3 secs', ZONE => PDT, NOW => 796720932], 796375329, ['now -4 days -3 secs', ZONE => PDT, NOW => 796720932], 796720928, ['now -4 secs', ZONE => PDT, NOW => 796720932], 796706532, ['now -4 hours', ZONE => PDT, NOW => 796720932], 796375329, ['-4 days -3 secs', ZONE => PDT, NOW => 796720932], 796375329, ['- 4 days -3 secs', ZONE => PDT, NOW => 796720932], 797322132, ['1 week', NOW => 796720932], 801987732, ['2 month', NOW => 796720932], 804579732, ['3 months', NOW => 796720932], 804579732, ['3 months, 7 days', NOW => 796720932, WHOLE => 0], # perhaps this is wrong 859879332, ['2 years', NOW => 796720932], 797671332, ['Wed after next', NOW => 796980132], 797498532, ['next monday', NOW => 796980132], 797584932, ['next tuesday', NOW => 796980132], 797584932, ['next tuesday, the 9th', NOW => 796980132, WHOLE => 0], # perhaps this is wrong 797066532, ['next wEd', NOW => 796980132], 796378932, ['last tuesday', NOW => 796980132], 796465332, ['last wednesday', NOW => 796980132], 796893732, ['last monday', NOW => 796980132], 797036400, ['today at 4pm', NOW => 796980132], 797080932, ['tomorrow +4hours', NOW => 796980132], 796950000, ['yesterday at 4pm', NOW => 796980132], 796378932, ['last week', NOW => 796980132], 794305332, ['last month', NOW => 796980132], 765444132, ['last year', NOW => 796980132], 797584932, ['next week', NOW => 796980132], 799572132, ['next month', NOW => 796980132], 828606132, ['next year', NOW => 796980132], 836391600, ['July 3rd, 4:00AM 1996 ', DATE_REQUIRED =>1, TIME_REQUIRED=>1, NO_RELATIVE=>1, NOW=>796980132], 783718105, ['Tue, 01 Nov 1994 11:28:25 -0800'], 202779300, ['5:35 pm june 4th CST 1976'], 236898000, ['5pm EDT 4th july 1977'], 236898000, ['5pm EDT 4 july 1977'], 819594300, ['21-dec 17:05', NOW => 796980132], 788058300, ['21-dec 17:05', NOW => 796980132, PREFER_PAST => 1], 819594300, ['21-dec 17:05', NOW => 796980132, PREFER_FUTURE => 1], 793415100, ['21-feb 17:05', NOW => 796980132, PREFER_PAST => 1], 824951100, ['21-feb 17:05', NOW => 796980132, PREFER_FUTURE => 1], 819594300, ['21/dec 17:05', NOW => 796980132], 756522300, ['21/dec/93 17:05'], 788058300, ['dec 21 1994 17:05'], 788058300, ['dec 21 94 17:05'], 788058300, ['dec 21 94 17:05'], 796465332, ['Wednesday', NOW => 796980132, PREFER_PAST => 1], 796378932, ['Tuesday', NOW => 796980132, PREFER_PAST => 1], 796893732, ['Monday', NOW => 796980132, PREFER_PAST => 1], 797066532, ['Wednesday', NOW => 796980132, PREFER_FUTURE => 1], 797584932, ['Tuesday', NOW => 796980132, PREFER_FUTURE => 1], 797498532, ['Monday', NOW => 796980132, PREFER_FUTURE => 1], 802915200, ['06/12/1995', ZONE => GMT], 828860438, ['06/Apr/1996:23:00:38 -0800'], 828860438, ['06/Apr/1996:23:00:38'], 828943238, ['07/Apr/1996:23:00:38 -0700'], 828878618, ['07/Apr/1996:12:03:38', ZONE => GMT], 828856838, ['06/Apr/1996:23:00:38 -0700'], 828946838, ['07/Apr/1996:23:00:38 -0800'], 895474800, ['5/18/1998'], 796980132, ['04/Apr/1995:00:22:12', ZONE => PDT], 796983732, ['04/Apr/1995:00:22:12 -0800'], 796983732, ['04/Apr/1995:00:22:12', ZONE => PST], 202772100, ['5:35 pm june 4th 1976 EDT'], 796892400, ['04/03', NOW => 796980132, PREFER_PAST => 1], 765702000, ['04/07', NOW => 796980132, PREFER_PAST => 1], 883641600, ['1/1/1998', VALIDATE => 1], 852105600, ['1/1/1997'], 852105600, ['last year', NOW => 883641600], 820483200, ['-2 years', NOW => 883641600], 832402800, ['-2 years', NOW => 895474800], 891864000, ['+3 days', NOW => 891608400], 891777600, ['+2 days', NOW => 891608400], 902938515, ['1998-08-12 12:15:15', ZONE => 'EDT'], 946684800, ['2000-01-01 00:00:00', ZONE => GMT], 1262304000, ['2010-01-01 00:00:00', ZONE => GMT], 757065600, ['12/28/93', NOW => 1262304000], 1924675200, ['12/28/30', NOW => 1262304000], 946751430, ['Jan 1 2000 10:30:30AM'], 946722083, ['Sat Jan 1 02:21:23 2000'], 946774740, ['Jan 1 2000 4:59PM', WHOLE => 1], 946774740, ['Jan 1 2000 4:59PM', WHOLE => 1], 0, ['1970/01/01 00:00:00', ZONE => GMT], 796980132, ['Tue 4 Apr 1995 00:22:12 PDT 8', WHOLE => 0], 789008700, ['dec 32 94 17:05'], 796983072, ['1995/04/04 00:71:12 PDT'], undef, ['1995/04/04 00:71:12 PDT', VALIDATE => 1], undef, ['38/38/21', VALIDATE => 1], undef, ['dec 32 94 17:05', VALIDATE => 1], undef, ['Tue 4 Apr 1995 00:22:12 PDT 8', WHOLE => 1], undef, ['Tue 4 Apr 199 00:22:12 PDT'], 1924675200, ['12/28/30', NOW => 1262304000, PREFUR_FUTURE => 1], 1924675200, ['28/12/30', NOW => 1262304000, PREFUR_FUTURE => 1, UK => 1], -1578240000, ['12/28/19', NOW => 902938515, PREFER_PAST => 1], -347155200, ['1959-01-01 00:00:00', ZONE => GMT], -158083200, ['12/28/64', NOW => 902938515], -1231084800, ['12/28/30', NOW => 1262304000, PREFER_PAST => 1], -345600, ['1969-12-28 00:00:00', ZONE => GMT], -1231084800, ['28/12/30', NOW => 1262304000, PREFER_PAST => 1, UK => 1], 1577520000, ['12/28/19', NOW => 902938515, PREFER_FUTURE => 1], 1766908800, ['12/28/25', NOW => 902938515], 958521600, ['17 May 2000 00:00:00 GMT'], 979718400, ['1/17/01', NOW => 993067736], 995353200, ['7/17/01', NOW => 993067736], 995353200, ['7/17/01', NOW => 993067736, PREFER_FUTURE => 1], 995366188, ['17/07/2001 18:36:28 +0800', WHOLE => 1], 995366188, ['17/07/2001 18:36:28+0800', WHOLE => 1], 995330188, ['17/07/2001 0:36:28+0000', WHOLE => 1], 995416588, ['17/07/2001 24:36:28+0000', WHOLE => 1], undef, ['17/07/2001 24:36:28+0000', WHOLE => 1, VALIDATE => 1], 995330188, ['17/07/2001 0:36:28+0000', WHOLE => 1, VALIDATE => 1], 796375332, ['4 days ago', WHOLE =>1, ZONE => PDT, NOW => 796720932], 796720931, ['1 second ago', WHOLE =>1, ZONE => PDT, NOW => 796720932], 796375331, ['4 days 1 second ago', WHOLE =>1, ZONE => PDT, NOW => 796720932], 796375331, ['1 second 4 days ago', WHOLE =>1, ZONE => PDT, NOW => 796720932], 953467299, ['Sun Mar 19 17:31:39 IST 2000'], 784111777, ['Sunday, 06-Nov-94 08:49:37 GMT' ], 954933672, ['Wed Apr 5 13:21:12 MET DST 2000' ], 729724230, ['1993-02-14T13:10:30', NOW => 796980132], 729724230, ['1993-02-14T13:10:30'], 729695430, ['1993-02-14T13:10:30Z'], 729695430, ['1993-02-14T13:10:30z'], undef, ['1993-02-14T13:10:30 z'], #ISO8601 729724230, ['19930214T131030', NOW => 796980132], 14400, ['+4 hours', NOW => 0], 345600, ['+4 days', NOW => 0], 957744000, ['Sunday before last', NOW => 958521600], 957139200, ['Sunday before last', NOW => 958348800], 796720930.5, ['1.5 second ago', WHOLE =>1.5, ZONE => PDT, NOW => 796720932], 796720930.5, ['1 1/2 second ago', WHOLE =>1.5, ZONE => PDT, NOW => 796720932], 5, ['5 seconds', UK => 1, NOW => 0], 6, ['5 seconds', UK => 1, NOW => 1], 1078876800, ['2004-03-10 00:00:00 GMT'], 1081551599, ['-1 second +1 month', NOW => 1078876800, ZONE => 'PDT'], 1081526399, ['-1 second +1 month', NOW => 1078876800, ZONE => 'GMT'], 1304661600, ['11pm', NOW => 1304611460], 1304636400, ['11pm', NOW => 1304611460, GMT => 1], 1304557200, ['1am', NOW => 1304611460, GMT => 1], 1246950000, ['2009/7/7'], -1636819200, ['1918/2/18'], 1246950000, ['2009/7/7'], 1256435700, ['2009-10-25 02:55:00', ZONE => 'MET'], 1256439300, ['+ 1 hour', NOW => 1256435700, ZONE => 'MET'], 1256464500, ['2009-10-25 02:55:00', ZONE => 'PDT'], 1256468100, ['+ 1 hour', NOW => 1256464500, ZONE => 'PDT'], 1256468100, ['2009-10-25 02:55:00', ZONE => 'PST'], 1256471700, ['+ 1 hour', NOW => 1256468100, ZONE => 'PST'], [1304622000, 'Foo'], ['12pm Foo', NOW => 1304611460, WHOLE => 0], undef, ['Foo 12pm', NOW => 1304611460, WHOLE => 0], undef, ['Foo noon', NOW => 1304611460, WHOLE => 0], undef, ['Foo midnight', NOW => 1304611460, WHOLE => 0], 1011252345, ['Wed Jan 16 23:25:45 2002'], 1012550400, ['Feb 1', NOW => 1011252345], 1012550400, ['Feb 1', NOW => 1011252345, FUZZY => 1, PREFER_FUTURE => 1], 1012550400, ['2/1/02', NOW => 1011252345, FUZZY => 1, PREFER_FUTURE => 1], 1011247200, ['6am', GMT => 1, NOW => 1011252345], 1256435700, ['2009-10-25 02:55:00', ZONE => 'MEZ'], 1348073459, ['2012-09-19 09:50:59'], 1348073459.344702843, ['2012-09-19 09:50:59.344702843', SUBSECOND => 1], 1304233200, ['May 1, 2011', WHOLE => 1], 1304233200, ['May 1, 2011', WHOLE => 0], 1301641200, ['April 1, 2011', WHOLE => 0], 1301641200, ['April 1, 2011', WHOLE => 1], ); %tztests = ( "YDT" => -8*3600, # Yukon Daylight "HDT" => -9*3600, # Hawaii Daylight "BST" => +1*3600, # British Summer "MEST" => +2*3600 # Middle European Summer ); } use Time::CTime; use Time::JulianDay; use Time::ParseDate; use Time::Local; use Time::Timezone; #use POSIX qw(tzset); #-use POSIX qw(tzset); # - -eval { tzset }; # Might not be implemented everywhere +use Time::Piece; #eval { tzset }; # Might not be implemented everywhere use Time::Piece; my @x = localtime(785307957); my @y = gmtime(785307957); my $hd = $y[2] - $x[2]; $hd += 24 if $hd < 0; $hd %= 24; if ($hd != 8) { print "1..0 # Skipped: It seems localtime() does not honor \$ENV{TZ} when set in the test script. Please set the TZ environment variable to PST8PDT and rerun."; print "hd = $hd, x = @x, y = @y\n" if $debug || -t STDOUT; exit 0; } my $before_big = $okat-1+scalar(keys %k)+scalar(keys %tztests); printf "1..%d\n", $before_big + scalar(grep(ref($_), @sdt)); print "ok 1\n"; $epoch = ($Time::JulianDay::jd_epoch - 2440588) * 86400 + $Time::JulianDay::jd_epoch_remainder; print STDERR "\nEpoch = $epoch\n" if $epoch; $etime = 785307957.5 - $epoch; eval " 1/0; "; # tests a bug in ctime! $x = ctime($etime); print $x eq "Sat Nov 19 21:05:57 PST 1994\n" ? "ok 2\n" : "not ok 2\n"; print julian_day(1994,11,19) == 2449676 ? "ok 3\n" : "not ok 3\n"; @x = inverse_julian_day(2449676); print (($x[0] == 1994 and $x[1] == 11 and $x[2] == 19) ? "ok 4\n" : "not ok 4\n"); print "ok 5\n"; print day_of_week(2449676) == 6 ? "ok 6\n" : "not ok 6\n"; $bs = 786439995 - $epoch; use vars qw($isdst $wday $yday); ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = gmtime($bs); $jdtgm = jd_timegm($sec,$min,$hour,$mday,$mon,$year); $jdtl = jd_timelocal($sec,$min,$hour,$mday,$mon,$year); $tltl = timelocal($sec,$min,$hour,$mday,$mon,$year); $year += 100 if $year < 70; $jd = julian_day($year+1900, $mon+1, $mday); $s = jd_secondsgm($jd, $hour, $min, $sec); $lo = tz_local_offset($bs); print <<"" if $debug; s = $s bs = $bs jdtgm = $jdtgm jdtl = $jdtl tltl = $tltl lo = $lo print $s == $bs ? "ok 7\n" : "not ok 7\n"; print $jdtgm == $bs ? "ok 8\n" : "not ok 8\n"; print $jdtl == $bs+8*3600 ? "ok 9\n" : "not ok 9\n"; print $tltl == $bs+8*3600 ? "ok 10\n" : "not ok 10\n"; print $lo == - 28800 ? "ok 11\n" : "no ok 11\n"; ################### make these last... $c = $okat; @lt = localtime($etime); $lt[0] += ($etime - int($etime)); foreach $i (sort keys %k) { $x = strftime("-%$i-", @lt); print $x eq "-$k{$i}-" ? "ok $c # $i - $k{$i}\n" : "not ok $c # $i - $k{$i}: $x\n"; if ($debug && $x ne "-$k{$i}-") { print "strftime(\"-%$i-\") = $x.\n\tshould be: $k{$i}.\n"; exit(0); } $c++; } foreach $i (keys %tztests) { $tzo = tz_offset($i,799572132); print $tzo eq $tztests{$i} ? "ok $c\n" : "not ok $c\n"; if (($debug || -t STDOUT) && $tzo ne $tztests{$i}) { print "tz_offset($i) = $tzo != $tztests{$i}\n"; exit(0); } $c++; } while (@sdt) { $es = shift(@sdt); my $eremaining; if (ref($es)) { $eremaining = $es->[1]; $es = $es->[0]; } $es -= $epoch if defined($es); $ar = shift(@sdt); $toparse = shift(@$ar); %opts = @$ar; if (defined $opts{NOW}) { $opts{NOW} -= $epoch; } $opts{WHOLE} = 1 unless defined $opts{WHOLE}; my $remaining; if (defined $eremaining) { ($s, $remaining) = parsedate($toparse, %opts); } else { $s = parsedate($toparse, %opts); } if (! defined($es) && ! defined($s)) { print "ok $c # $toparse\n"; } elsif (defined($es) && defined($s) && ($es == $s || "$es" eq "$s")) { print "ok $c # $toparse\n"; } else { print "not ok $c # $toparse\n"; if (-t STDOUT || $debug) { if (defined($es)) { print strftime("Expected($es): %c %Z\n", localtime($es)); } else { print "Expected undef\n"; } $s = 0 unless defined $s; print strftime("\tGot($s): %c %Z", localtime($s)); print strftime(" (%m/%d %I:%M %p GMT)\n", gmtime($s)); print "\tInput: $toparse\n"; for my $zk (keys %opts) { my $zv = $opts{$zk}; if ($zk eq 'NOW') { print strftime("\t\tNOW => %c %Z\n", localtime($zv)); } else { print "\t\t$zk => $zv\n"; } } if (-t STDOUT) { print "The parse...\n"; $Time::ParseDate::debug = 1; &parsedate($toparse, %opts); printf "Test that failed was on line %d\n", $c-$before_big+$sdt_start_line-1; exit(0); } } } if (defined($eremaining)) { $c++; if ($remaining eq $eremaining) { print "ok $c # remaining = '$eremaining'\n"; } else { print "not ok $c # remaining = '$eremaining'\n"; if (-t STDOUT || $debug) { print "# got '$remaining' instead\n"; } } } $c++; } Time-ParseDate-2026.0219/t/PaxHeader/metdate.t000644 000765 000024 00000000350 15145615731 021424 xustar00jbrandtstaff000000 000000 30 mtime=1771510745.813137416 53 LIBARCHIVE.xattr.com.macromates.visibleIndex=Mzky 48 SCHILY.xattr.com.macromates.visibleIndex=392 53 LIBARCHIVE.xattr.com.macromates.selectionRange=MQ 48 SCHILY.xattr.com.macromates.selectionRange=1 Time-ParseDate-2026.0219/t/metdate.t000644 000765 000024 00000003311 15145615731 017453 0ustar00jbrandtstaff000000 000000 #!/usr/bin/perl -I. -w use strict; use warnings; use Test::More; use Time::ParseDate; use Time::CTime; #-use POSIX qw(tzset); use Time::Piece; my $finished; END { ok($finished, 'finished') if defined $finished } $ENV{'LANG'} = 'C'; $ENV{'TZ'} = 'PST8PDT'; my @x = localtime(785307957); my @y = gmtime(785307957); my $hd = $y[2] - $x[2]; $hd += 24 if $hd < 0; $hd %= 24; if ($hd != 8) { plan skip_all => "It seems localtime() does not honor \$ENV{TZ} when set in the test script."; exit 0; } $ENV{'TZ'} = 'MET'; @x = localtime(785307957); @y = gmtime(785307957); $hd = $y[2] - $x[2]; $hd += 24 if $hd < 0; $hd %= 24; if ($hd != 23) { plan skip_all => "It seems localtime() does not honor \$ENV{TZ} when set in the test script."; exit 0; } plan 'no_plan'; $finished = 0; $ENV{TZ} = 'MET'; my $t0 = parsedate("2009-10-25 02:55:00"); my $t1 = parsedate("+ 1 hour", NOW => scalar(parsedate("2009-10-25 02:55:00"))); my $lt1 = scalar(localtime($t1)); is($t0, 1256435700, "testing TZ=MET seconds"); is($t1, 1256439300, "testing TZ=MET seconds +1 h"); is($lt1, "Sun Oct 25 03:55:00 2009", "testing TZ=MET +1 h localtime"); $ENV{TZ} = "PST8PDT"; my $p0 = parsedate("2009-11-01 01:55:00"); my $p1 = parsedate("+ 1 hour", NOW => scalar(parsedate("2009-11-01 01:55:00"))); my $lp0 = scalar(localtime($p0)); my $lp1 = scalar(localtime($p1)); my $lpz0 = strftime("%R %Z",localtime($p0)); my $lpz1 = strftime("%R %Z",localtime($p1)); is($p0, 1257065700, "testing PST8PDT"); is($lp0, "Sun Nov 1 01:55:00 2009", "testing PST8PDT localtime"); is($p1, 1257069300, "testing PST8PDT"); is($lp1, "Sun Nov 1 01:55:00 2009", "testing PST8PDT localtime"); is($lpz0, "01:55 PDT", "zone 0"); is($lpz1, "01:55 PST", "zone 1"); $finished = 1; Time-ParseDate-2026.0219/t/dst.t000644 000765 000024 00000003233 15150357775 016634 0ustar00jbrandtstaff000000 000000 #!/usr/bin/perl use strict; use warnings; use Test::More; eval { require Test::MockTime }; if ($@) { plan skip_all => 'Test::MockTime required for this test'; } Test::MockTime->import('set_fixed_time', 'restore_time'); use_ok( 'Time::ParseDate' ); $ENV{'LANG'} = 'C'; $ENV{'TZ'} = 'PST8PDT'; # Verify that setting $ENV{TZ} actually affects localtime() on this # platform. Not all systems honor TZ changes within a running process. my @x = localtime(785307957); my @y = gmtime(785307957); my $hd = $y[2] - $x[2]; $hd += 24 if $hd < 0; $hd %= 24; if ($hd != 8) { plan skip_all => "It seems localtime() does not honor \$ENV{TZ} when set in the test script."; exit 0; } # Verify that parsing a date returns the correct epoch regardless of # whether the system clock and the parsed date are in different DST states. # https://github.com/muir/Time-modules/issues/8 # Clock in summer, parse a winter date set_fixed_time(962409600); # 2000-06-30 PDT is(parsedate('1969/12/31 16:00:00', WHOLE => 1), 0, 'winter date parsed when clock is in summer'); restore_time(); # Clock in winter, parse a summer date set_fixed_time(946684800); # 2000-01-01 PST is(parsedate('2000/07/04 12:00:00', WHOLE => 1), 962737200, 'summer date parsed when clock is in winter'); restore_time(); # Clock and parsed date in the same DST state set_fixed_time(962409600); # 2000-06-30 PDT is(parsedate('2000/07/04 12:00:00', WHOLE => 1), 962737200, 'summer date parsed when clock is in summer'); restore_time(); set_fixed_time(946684800); # 2000-01-01 PST is(parsedate('1969/12/31 16:00:00', WHOLE => 1), 0, 'winter date parsed when clock is in winter'); restore_time(); done_testing(); Time-ParseDate-2026.0219/t/rt96453.t000644 000765 000024 00000001214 15145615731 017070 0ustar00jbrandtstaff000000 000000 use Test::More; use_ok( Time::ParseDate ); $ENV{'TZ'} = 'UTC'; is(parsedate('Wed Dec 31 23:59:59 1969', WHOLE => 1), -1, "UTC 1 second before epoch"); is(parsedate('Thu Jan 01 00:00:00 1970', WHOLE => 1), 0, "UTC epoch second 0"); is(parsedate('Thu Jan 01 00:00:01 1970', WHOLE => 1), 1, "UTC 1 second after epoch"); $ENV{'TZ'} = 'MST7MDT'; is(parsedate('Wed Dec 31 16:59:59 1969', WHOLE => 1), -1, "MST7MDT 1 second before epoch"); is(parsedate('Wed Dec 31 17:00:00 1969', WHOLE => 1), 0, "MST7MDT epoch second 0"); is(parsedate('Wed Dec 31 17:00:01 1969', WHOLE => 1), 1, "MST7MDT 1 second after epoch"); done_testing();Time-ParseDate-2026.0219/inc/Module/000755 000765 000024 00000000000 15150360352 017370 5ustar00jbrandtstaff000000 000000 Time-ParseDate-2026.0219/inc/Module/Install/000755 000765 000024 00000000000 15150360352 020776 5ustar00jbrandtstaff000000 000000 Time-ParseDate-2026.0219/inc/Module/Install.pm000644 000765 000024 00000027145 15150357775 021364 0ustar00jbrandtstaff000000 000000 #line 1 package Module::Install; # For any maintainers: # The load order for Module::Install is a bit magic. # It goes something like this... # # IF ( host has Module::Install installed, creating author mode ) { # 1. Makefile.PL calls "use inc::Module::Install" # 2. $INC{inc/Module/Install.pm} set to installed version of inc::Module::Install # 3. The installed version of inc::Module::Install loads # 4. inc::Module::Install calls "require Module::Install" # 5. The ./inc/ version of Module::Install loads # } ELSE { # 1. Makefile.PL calls "use inc::Module::Install" # 2. $INC{inc/Module/Install.pm} set to ./inc/ version of Module::Install # 3. The ./inc/ version of Module::Install loads # } use 5.006; use strict 'vars'; use Cwd (); use File::Find (); use File::Path (); use vars qw{$VERSION $MAIN}; BEGIN { # All Module::Install core packages now require synchronised versions. # This will be used to ensure we don't accidentally load old or # different versions of modules. # This is not enforced yet, but will be some time in the next few # releases once we can make sure it won't clash with custom # Module::Install extensions. $VERSION = '1.21'; # Storage for the pseudo-singleton $MAIN = undef; *inc::Module::Install::VERSION = *VERSION; @inc::Module::Install::ISA = __PACKAGE__; } sub import { my $class = shift; my $self = $class->new(@_); my $who = $self->_caller; #------------------------------------------------------------- # all of the following checks should be included in import(), # to allow "eval 'require Module::Install; 1' to test # installation of Module::Install. (RT #51267) #------------------------------------------------------------- # Whether or not inc::Module::Install is actually loaded, the # $INC{inc/Module/Install.pm} is what will still get set as long as # the caller loaded module this in the documented manner. # If not set, the caller may NOT have loaded the bundled version, and thus # they may not have a MI version that works with the Makefile.PL. This would # result in false errors or unexpected behaviour. And we don't want that. my $file = join( '/', 'inc', split /::/, __PACKAGE__ ) . '.pm'; unless ( $INC{$file} ) { die <<"END_DIE" } Please invoke ${\__PACKAGE__} with: use inc::${\__PACKAGE__}; not: use ${\__PACKAGE__}; END_DIE # This reportedly fixes a rare Win32 UTC file time issue, but # as this is a non-cross-platform XS module not in the core, # we shouldn't really depend on it. See RT #24194 for detail. # (Also, this module only supports Perl 5.6 and above). eval "use Win32::UTCFileTime" if $^O eq 'MSWin32' && $] >= 5.006; # If the script that is loading Module::Install is from the future, # then make will detect this and cause it to re-run over and over # again. This is bad. Rather than taking action to touch it (which # is unreliable on some platforms and requires write permissions) # for now we should catch this and refuse to run. if ( -f $0 ) { my $s = (stat($0))[9]; # If the modification time is only slightly in the future, # sleep briefly to remove the problem. my $a = $s - time; if ( $a > 0 and $a < 5 ) { sleep 5 } # Too far in the future, throw an error. my $t = time; if ( $s > $t ) { die <<"END_DIE" } Your installer $0 has a modification time in the future ($s > $t). This is known to create infinite loops in make. Please correct this, then run $0 again. END_DIE } # Build.PL was formerly supported, but no longer is due to excessive # difficulty in implementing every single feature twice. if ( $0 =~ /Build.PL$/i ) { die <<"END_DIE" } Module::Install no longer supports Build.PL. It was impossible to maintain duel backends, and has been deprecated. Please remove all Build.PL files and only use the Makefile.PL installer. END_DIE #------------------------------------------------------------- # To save some more typing in Module::Install installers, every... # use inc::Module::Install # ...also acts as an implicit use strict. $^H |= strict::bits(qw(refs subs vars)); #------------------------------------------------------------- unless ( -f $self->{file} ) { foreach my $key (keys %INC) { delete $INC{$key} if $key =~ /Module\/Install/; } local $^W; require "$self->{path}/$self->{dispatch}.pm"; File::Path::mkpath("$self->{prefix}/$self->{author}"); $self->{admin} = "$self->{name}::$self->{dispatch}"->new( _top => $self ); $self->{admin}->init; @_ = ($class, _self => $self); goto &{"$self->{name}::import"}; } local $^W; *{"${who}::AUTOLOAD"} = $self->autoload; $self->preload; # Unregister loader and worker packages so subdirs can use them again delete $INC{'inc/Module/Install.pm'}; delete $INC{'Module/Install.pm'}; # Save to the singleton $MAIN = $self; return 1; } sub autoload { my $self = shift; my $who = $self->_caller; my $cwd = Cwd::getcwd(); my $sym = "${who}::AUTOLOAD"; $sym->{$cwd} = sub { my $pwd = Cwd::getcwd(); if ( my $code = $sym->{$pwd} ) { # Delegate back to parent dirs goto &$code unless $cwd eq $pwd; } unless ($$sym =~ s/([^:]+)$//) { # XXX: it looks like we can't retrieve the missing function # via $$sym (usually $main::AUTOLOAD) in this case. # I'm still wondering if we should slurp Makefile.PL to # get some context or not ... my ($package, $file, $line) = caller; die <<"EOT"; Unknown function is found at $file line $line. Execution of $file aborted due to runtime errors. If you're a contributor to a project, you may need to install some Module::Install extensions from CPAN (or other repository). If you're a user of a module, please contact the author. EOT } my $method = $1; if ( uc($method) eq $method ) { # Do nothing return; } elsif ( $method =~ /^_/ and $self->can($method) ) { # Dispatch to the root M:I class return $self->$method(@_); } # Dispatch to the appropriate plugin unshift @_, ( $self, $1 ); goto &{$self->can('call')}; }; } sub preload { my $self = shift; unless ( $self->{extensions} ) { $self->load_extensions( "$self->{prefix}/$self->{path}", $self ); } my @exts = @{$self->{extensions}}; unless ( @exts ) { @exts = $self->{admin}->load_all_extensions; } my %seen; foreach my $obj ( @exts ) { while (my ($method, $glob) = each %{ref($obj) . '::'}) { next unless $obj->can($method); next if $method =~ /^_/; next if $method eq uc($method); $seen{$method}++; } } my $who = $self->_caller; foreach my $name ( sort keys %seen ) { local $^W; *{"${who}::$name"} = sub { ${"${who}::AUTOLOAD"} = "${who}::$name"; goto &{"${who}::AUTOLOAD"}; }; } } sub new { my ($class, %args) = @_; delete $INC{'FindBin.pm'}; { # to suppress the redefine warning local $SIG{__WARN__} = sub {}; require FindBin; } # ignore the prefix on extension modules built from top level. my $base_path = Cwd::abs_path($FindBin::Bin); unless ( Cwd::abs_path(Cwd::getcwd()) eq $base_path ) { delete $args{prefix}; } return $args{_self} if $args{_self}; $base_path = VMS::Filespec::unixify($base_path) if $^O eq 'VMS'; $args{dispatch} ||= 'Admin'; $args{prefix} ||= 'inc'; $args{author} ||= ($^O eq 'VMS' ? '_author' : '.author'); $args{bundle} ||= 'inc/BUNDLES'; $args{base} ||= $base_path; $class =~ s/^\Q$args{prefix}\E:://; $args{name} ||= $class; $args{version} ||= $class->VERSION; unless ( $args{path} ) { $args{path} = $args{name}; $args{path} =~ s!::!/!g; } $args{file} ||= "$args{base}/$args{prefix}/$args{path}.pm"; $args{wrote} = 0; bless( \%args, $class ); } sub call { my ($self, $method) = @_; my $obj = $self->load($method) or return; splice(@_, 0, 2, $obj); goto &{$obj->can($method)}; } sub load { my ($self, $method) = @_; $self->load_extensions( "$self->{prefix}/$self->{path}", $self ) unless $self->{extensions}; foreach my $obj (@{$self->{extensions}}) { return $obj if $obj->can($method); } my $admin = $self->{admin} or die <<"END_DIE"; The '$method' method does not exist in the '$self->{prefix}' path! Please remove the '$self->{prefix}' directory and run $0 again to load it. END_DIE my $obj = $admin->load($method, 1); push @{$self->{extensions}}, $obj; $obj; } sub load_extensions { my ($self, $path, $top) = @_; my $should_reload = 0; unless ( grep { ! ref $_ and lc $_ eq lc $self->{prefix} } @INC ) { unshift @INC, $self->{prefix}; $should_reload = 1; } foreach my $rv ( $self->find_extensions($path) ) { my ($file, $pkg) = @{$rv}; next if $self->{pathnames}{$pkg}; local $@; my $new = eval { local $^W; require $file; $pkg->can('new') }; unless ( $new ) { warn $@ if $@; next; } $self->{pathnames}{$pkg} = $should_reload ? delete $INC{$file} : $INC{$file}; push @{$self->{extensions}}, &{$new}($pkg, _top => $top ); } $self->{extensions} ||= []; } sub find_extensions { my ($self, $path) = @_; my @found; File::Find::find( {no_chdir => 1, wanted => sub { my $file = $File::Find::name; return unless $file =~ m!^\Q$path\E/(.+)\.pm\Z!is; my $subpath = $1; return if lc($subpath) eq lc($self->{dispatch}); $file = "$self->{path}/$subpath.pm"; my $pkg = "$self->{name}::$subpath"; $pkg =~ s!/!::!g; # If we have a mixed-case package name, assume case has been preserved # correctly. Otherwise, root through the file to locate the case-preserved # version of the package name. if ( $subpath eq lc($subpath) || $subpath eq uc($subpath) ) { my $content = Module::Install::_read($File::Find::name); my $in_pod = 0; foreach ( split /\n/, $content ) { $in_pod = 1 if /^=\w/; $in_pod = 0 if /^=cut/; next if ($in_pod || /^=cut/); # skip pod text next if /^\s*#/; # and comments if ( m/^\s*package\s+($pkg)\s*;/i ) { $pkg = $1; last; } } } push @found, [ $file, $pkg ]; }}, $path ) if -d $path; @found; } ##################################################################### # Common Utility Functions sub _caller { my $depth = 0; my $call = caller($depth); while ( $call eq __PACKAGE__ ) { $depth++; $call = caller($depth); } return $call; } sub _read { local *FH; open( FH, '<', $_[0] ) or die "open($_[0]): $!"; binmode FH; my $string = do { local $/; }; close FH or die "close($_[0]): $!"; return $string; } sub _readperl { my $string = Module::Install::_read($_[0]); $string =~ s/(?:\015{1,2}\012|\015|\012)/\n/sg; $string =~ s/(\n)\n*__(?:DATA|END)__\b.*\z/$1/s; $string =~ s/\n\n=\w+.+?\n\n=cut\b.+?\n+/\n\n/sg; return $string; } sub _readpod { my $string = Module::Install::_read($_[0]); $string =~ s/(?:\015{1,2}\012|\015|\012)/\n/sg; return $string if $_[0] =~ /\.pod\z/; $string =~ s/(^|\n=cut\b.+?\n+)[^=\s].+?\n(\n=\w+|\z)/$1$2/sg; $string =~ s/\n*=pod\b[^\n]*\n+/\n\n/sg; $string =~ s/\n*=cut\b[^\n]*\n+/\n\n/sg; $string =~ s/^\n+//s; return $string; } sub _write { local *FH; open( FH, '>', $_[0] ) or die "open($_[0]): $!"; binmode FH; foreach ( 1 .. $#_ ) { print FH $_[$_] or die "print($_[0]): $!"; } close FH or die "close($_[0]): $!"; } # _version is for processing module versions (eg, 1.03_05) not # Perl versions (eg, 5.8.1). sub _version { my $s = shift || 0; my $d =()= $s =~ /(\.)/g; if ( $d >= 2 ) { # Normalise multipart versions $s =~ s/(\.)(\d{1,3})/sprintf("$1%03d",$2)/eg; } $s =~ s/^(\d+)\.?//; my $l = $1 || 0; my @v = map { $_ . '0' x (3 - length $_) } $s =~ /(\d{1,3})\D?/g; $l = $l . '.' . join '', @v if @v; return $l + 0; } sub _cmp { _version($_[1]) <=> _version($_[2]); } # Cloned from Params::Util::_CLASS sub _CLASS { ( defined $_[0] and ! ref $_[0] and $_[0] =~ m/^[^\W\d]\w*(?:::\w+)*\z/s ) ? $_[0] : undef; } 1; # Copyright 2008 - 2012 Adam Kennedy. Time-ParseDate-2026.0219/inc/Module/Install/Fetch.pm000644 000765 000024 00000004627 15150357775 022415 0ustar00jbrandtstaff000000 000000 #line 1 package Module::Install::Fetch; use strict; use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.21'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } sub get_file { my ($self, %args) = @_; my ($scheme, $host, $path, $file) = $args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return; if ( $scheme eq 'http' and ! eval { require LWP::Simple; 1 } ) { $args{url} = $args{ftp_url} or (warn("LWP support unavailable!\n"), return); ($scheme, $host, $path, $file) = $args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return; } $|++; print "Fetching '$file' from $host... "; unless (eval { require Socket; Socket::inet_aton($host) }) { warn "'$host' resolve failed!\n"; return; } return unless $scheme eq 'ftp' or $scheme eq 'http'; require Cwd; my $dir = Cwd::getcwd(); chdir $args{local_dir} or return if exists $args{local_dir}; if (eval { require LWP::Simple; 1 }) { LWP::Simple::mirror($args{url}, $file); } elsif (eval { require Net::FTP; 1 }) { eval { # use Net::FTP to get past firewall my $ftp = Net::FTP->new($host, Passive => 1, Timeout => 600); $ftp->login("anonymous", 'anonymous@example.com'); $ftp->cwd($path); $ftp->binary; $ftp->get($file) or (warn("$!\n"), return); $ftp->quit; } } elsif (my $ftp = $self->can_run('ftp')) { eval { # no Net::FTP, fallback to ftp.exe require FileHandle; my $fh = FileHandle->new; local $SIG{CHLD} = 'IGNORE'; unless ($fh->open("|$ftp -n")) { warn "Couldn't open ftp: $!\n"; chdir $dir; return; } my @dialog = split(/\n/, <<"END_FTP"); open $host user anonymous anonymous\@example.com cd $path binary get $file $file quit END_FTP foreach (@dialog) { $fh->print("$_\n") } $fh->close; } } else { warn "No working 'ftp' program available!\n"; chdir $dir; return; } unless (-f $file) { warn "Fetching failed: $@\n"; chdir $dir; return; } return if exists $args{size} and -s $file != $args{size}; system($args{run}) if exists $args{run}; unlink($file) if $args{remove}; print(((!exists $args{check_for} or -e $args{check_for}) ? "done!" : "failed! ($!)"), "\n"); chdir $dir; return !$?; } 1; Time-ParseDate-2026.0219/inc/Module/Install/Metadata.pm000644 000765 000024 00000043437 15150357775 023106 0ustar00jbrandtstaff000000 000000 #line 1 package Module::Install::Metadata; use strict 'vars'; use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.21'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } my @boolean_keys = qw{ sign }; my @scalar_keys = qw{ name module_name abstract version distribution_type tests installdirs }; my @tuple_keys = qw{ configure_requires build_requires requires recommends bundles resources }; my @resource_keys = qw{ homepage bugtracker repository }; my @array_keys = qw{ keywords author }; *authors = \&author; sub Meta { shift } sub Meta_BooleanKeys { @boolean_keys } sub Meta_ScalarKeys { @scalar_keys } sub Meta_TupleKeys { @tuple_keys } sub Meta_ResourceKeys { @resource_keys } sub Meta_ArrayKeys { @array_keys } foreach my $key ( @boolean_keys ) { *$key = sub { my $self = shift; if ( defined wantarray and not @_ ) { return $self->{values}->{$key}; } $self->{values}->{$key} = ( @_ ? $_[0] : 1 ); return $self; }; } foreach my $key ( @scalar_keys ) { *$key = sub { my $self = shift; return $self->{values}->{$key} if defined wantarray and !@_; $self->{values}->{$key} = shift; return $self; }; } foreach my $key ( @array_keys ) { *$key = sub { my $self = shift; return $self->{values}->{$key} if defined wantarray and !@_; $self->{values}->{$key} ||= []; push @{$self->{values}->{$key}}, @_; return $self; }; } foreach my $key ( @resource_keys ) { *$key = sub { my $self = shift; unless ( @_ ) { return () unless $self->{values}->{resources}; return map { $_->[1] } grep { $_->[0] eq $key } @{ $self->{values}->{resources} }; } return $self->{values}->{resources}->{$key} unless @_; my $uri = shift or die( "Did not provide a value to $key()" ); $self->resources( $key => $uri ); return 1; }; } foreach my $key ( grep { $_ ne "resources" } @tuple_keys) { *$key = sub { my $self = shift; return $self->{values}->{$key} unless @_; my @added; while ( @_ ) { my $module = shift or last; my $version = shift || 0; push @added, [ $module, $version ]; } push @{ $self->{values}->{$key} }, @added; return map {@$_} @added; }; } # Resource handling my %lc_resource = map { $_ => 1 } qw{ homepage license bugtracker repository }; sub resources { my $self = shift; while ( @_ ) { my $name = shift or last; my $value = shift or next; if ( $name eq lc $name and ! $lc_resource{$name} ) { die("Unsupported reserved lowercase resource '$name'"); } $self->{values}->{resources} ||= []; push @{ $self->{values}->{resources} }, [ $name, $value ]; } $self->{values}->{resources}; } # Aliases for build_requires that will have alternative # meanings in some future version of META.yml. sub test_requires { shift->build_requires(@_) } sub install_requires { shift->build_requires(@_) } # Aliases for installdirs options sub install_as_core { $_[0]->installdirs('perl') } sub install_as_cpan { $_[0]->installdirs('site') } sub install_as_site { $_[0]->installdirs('site') } sub install_as_vendor { $_[0]->installdirs('vendor') } sub dynamic_config { my $self = shift; my $value = @_ ? shift : 1; if ( $self->{values}->{dynamic_config} ) { # Once dynamic we never change to static, for safety return 0; } $self->{values}->{dynamic_config} = $value ? 1 : 0; return 1; } # Convenience command sub static_config { shift->dynamic_config(0); } sub perl_version { my $self = shift; return $self->{values}->{perl_version} unless @_; my $version = shift or die( "Did not provide a value to perl_version()" ); # Normalize the version $version = $self->_perl_version($version); # We don't support the really old versions unless ( $version >= 5.005 ) { die "Module::Install only supports 5.005 or newer (use ExtUtils::MakeMaker)\n"; } $self->{values}->{perl_version} = $version; } sub all_from { my ( $self, $file ) = @_; unless ( defined($file) ) { my $name = $self->name or die( "all_from called with no args without setting name() first" ); $file = join('/', 'lib', split(/-/, $name)) . '.pm'; $file =~ s{.*/}{} unless -e $file; unless ( -e $file ) { die("all_from cannot find $file from $name"); } } unless ( -f $file ) { die("The path '$file' does not exist, or is not a file"); } $self->{values}{all_from} = $file; # Some methods pull from POD instead of code. # If there is a matching .pod, use that instead my $pod = $file; $pod =~ s/\.pm$/.pod/i; $pod = $file unless -e $pod; # Pull the different values $self->name_from($file) unless $self->name; $self->version_from($file) unless $self->version; $self->perl_version_from($file) unless $self->perl_version; $self->author_from($pod) unless @{$self->author || []}; $self->license_from($pod) unless $self->license; $self->abstract_from($pod) unless $self->abstract; return 1; } sub provides { my $self = shift; my $provides = ( $self->{values}->{provides} ||= {} ); %$provides = (%$provides, @_) if @_; return $provides; } sub auto_provides { my $self = shift; return $self unless $self->is_admin; unless (-e 'MANIFEST') { warn "Cannot deduce auto_provides without a MANIFEST, skipping\n"; return $self; } # Avoid spurious warnings as we are not checking manifest here. local $SIG{__WARN__} = sub {1}; require ExtUtils::Manifest; local *ExtUtils::Manifest::manicheck = sub { return }; require Module::Build; my $build = Module::Build->new( dist_name => $self->name, dist_version => $self->version, license => $self->license, ); $self->provides( %{ $build->find_dist_packages || {} } ); } sub feature { my $self = shift; my $name = shift; my $features = ( $self->{values}->{features} ||= [] ); my $mods; if ( @_ == 1 and ref( $_[0] ) ) { # The user used ->feature like ->features by passing in the second # argument as a reference. Accomodate for that. $mods = $_[0]; } else { $mods = \@_; } my $count = 0; push @$features, ( $name => [ map { ref($_) ? ( ref($_) eq 'HASH' ) ? %$_ : @$_ : $_ } @$mods ] ); return @$features; } sub features { my $self = shift; while ( my ( $name, $mods ) = splice( @_, 0, 2 ) ) { $self->feature( $name, @$mods ); } return $self->{values}->{features} ? @{ $self->{values}->{features} } : (); } sub no_index { my $self = shift; my $type = shift; push @{ $self->{values}->{no_index}->{$type} }, @_ if $type; return $self->{values}->{no_index}; } sub read { my $self = shift; $self->include_deps( 'YAML::Tiny', 0 ); require YAML::Tiny; my $data = YAML::Tiny::LoadFile('META.yml'); # Call methods explicitly in case user has already set some values. while ( my ( $key, $value ) = each %$data ) { next unless $self->can($key); if ( ref $value eq 'HASH' ) { while ( my ( $module, $version ) = each %$value ) { $self->can($key)->($self, $module => $version ); } } else { $self->can($key)->($self, $value); } } return $self; } sub write { my $self = shift; return $self unless $self->is_admin; $self->admin->write_meta; return $self; } sub version_from { require ExtUtils::MM_Unix; my ( $self, $file ) = @_; $self->version( ExtUtils::MM_Unix->parse_version($file) ); # for version integrity check $self->makemaker_args( VERSION_FROM => $file ); } sub abstract_from { require ExtUtils::MM_Unix; my ( $self, $file ) = @_; $self->abstract( bless( { DISTNAME => $self->name }, 'ExtUtils::MM_Unix' )->parse_abstract($file) ); } # Add both distribution and module name sub name_from { my ($self, $file) = @_; if ( Module::Install::_read($file) =~ m/ ^ \s* package \s* ([\w:]+) [\s|;]* /ixms ) { my ($name, $module_name) = ($1, $1); $name =~ s{::}{-}g; $self->name($name); unless ( $self->module_name ) { $self->module_name($module_name); } } else { die("Cannot determine name from $file\n"); } } sub _extract_perl_version { if ( $_[0] =~ m/ ^\s* (?:use|require) \s* v? ([\d_\.]+) \s* ; /ixms ) { my $perl_version = $1; $perl_version =~ s{_}{}g; return $perl_version; } else { return; } } sub perl_version_from { my $self = shift; my $perl_version=_extract_perl_version(Module::Install::_read($_[0])); if ($perl_version) { $self->perl_version($perl_version); } else { warn "Cannot determine perl version info from $_[0]\n"; return; } } sub author_from { my $self = shift; my $content = Module::Install::_read($_[0]); if ($content =~ m/ =head \d \s+ (?:authors?)\b \s* ([^\n]*) | =head \d \s+ (?:licen[cs]e|licensing|copyright|legal)\b \s* .*? copyright .*? \d\d\d[\d.]+ \s* (?:\bby\b)? \s* ([^\n]*) /ixms) { my $author = $1 || $2; # XXX: ugly but should work anyway... if (eval "require Pod::Escapes; 1") { # Pod::Escapes has a mapping table. # It's in core of perl >= 5.9.3, and should be installed # as one of the Pod::Simple's prereqs, which is a prereq # of Pod::Text 3.x (see also below). $author =~ s{ E<( (\d+) | ([A-Za-z]+) )> } { defined $2 ? chr($2) : defined $Pod::Escapes::Name2character_number{$1} ? chr($Pod::Escapes::Name2character_number{$1}) : do { warn "Unknown escape: E<$1>"; "E<$1>"; }; }gex; } elsif (eval "require Pod::Text; 1" && $Pod::Text::VERSION < 3) { # Pod::Text < 3.0 has yet another mapping table, # though the table name of 2.x and 1.x are different. # (1.x is in core of Perl < 5.6, 2.x is in core of # Perl < 5.9.3) my $mapping = ($Pod::Text::VERSION < 2) ? \%Pod::Text::HTML_Escapes : \%Pod::Text::ESCAPES; $author =~ s{ E<( (\d+) | ([A-Za-z]+) )> } { defined $2 ? chr($2) : defined $mapping->{$1} ? $mapping->{$1} : do { warn "Unknown escape: E<$1>"; "E<$1>"; }; }gex; } else { $author =~ s{E}{<}g; $author =~ s{E}{>}g; } $self->author($author); } else { warn "Cannot determine author info from $_[0]\n"; } } #Stolen from M::B my %license_urls = ( perl => 'http://dev.perl.org/licenses/', apache => 'http://apache.org/licenses/LICENSE-2.0', artistic => 'http://opensource.org/licenses/artistic-license.php', lgpl => 'http://opensource.org/licenses/lgpl-license.php', bsd => 'http://opensource.org/licenses/bsd-license.php', gpl => 'http://opensource.org/licenses/gpl-license.php', gpl2 => 'http://opensource.org/licenses/gpl-2.0.php', gpl3 => 'http://opensource.org/licenses/gpl-3.0.html', mit => 'http://opensource.org/licenses/mit-license.php', mozilla => 'http://opensource.org/licenses/mozilla1.1.php', open_source => undef, unrestricted => undef, restrictive => undef, unknown => undef, # these are not actually allowed in meta-spec v1.4 but are left here for compatibility: apache_1_1 => 'http://apache.org/licenses/LICENSE-1.1', artistic_2 => 'http://opensource.org/licenses/artistic-license-2.0.php', lgpl2 => 'http://opensource.org/licenses/lgpl-2.1.php', lgpl3 => 'http://opensource.org/licenses/lgpl-3.0.html', ); sub license { my $self = shift; return $self->{values}->{license} unless @_; my $license = shift or die( 'Did not provide a value to license()' ); $license = __extract_license($license) || lc $license; $self->{values}->{license} = $license; # Automatically fill in license URLs if ( $license_urls{$license} ) { $self->resources( license => $license_urls{$license} ); } return 1; } sub _extract_license { my $pod = shift; my $matched; return __extract_license( ($matched) = $pod =~ m/ (=head \d \s+ L(?i:ICEN[CS]E|ICENSING)\b.*?) (=head \d.*|=cut.*|)\z /xms ) || __extract_license( ($matched) = $pod =~ m/ (=head \d \s+ (?:C(?i:OPYRIGHTS?)|L(?i:EGAL))\b.*?) (=head \d.*|=cut.*|)\z /xms ); } sub __extract_license { my $license_text = shift or return; my @phrases = ( '(?:under )?the same (?:terms|license) as (?:perl|the perl (?:\d )?programming language)' => 'perl', 1, '(?:under )?the terms of (?:perl|the perl programming language) itself' => 'perl', 1, 'Artistic and GPL' => 'perl', 1, 'GNU general public license' => 'gpl', 1, 'GNU public license' => 'gpl', 1, 'GNU lesser general public license' => 'lgpl', 1, 'GNU lesser public license' => 'lgpl', 1, 'GNU library general public license' => 'lgpl', 1, 'GNU library public license' => 'lgpl', 1, 'GNU Free Documentation license' => 'unrestricted', 1, 'GNU Affero General Public License' => 'open_source', 1, '(?:Free)?BSD license' => 'bsd', 1, 'Artistic license 2\.0' => 'artistic_2', 1, 'Artistic license' => 'artistic', 1, 'Apache (?:Software )?license' => 'apache', 1, 'GPL' => 'gpl', 1, 'LGPL' => 'lgpl', 1, 'BSD' => 'bsd', 1, 'Artistic' => 'artistic', 1, 'MIT' => 'mit', 1, 'Mozilla Public License' => 'mozilla', 1, 'Q Public License' => 'open_source', 1, 'OpenSSL License' => 'unrestricted', 1, 'SSLeay License' => 'unrestricted', 1, 'zlib License' => 'open_source', 1, 'proprietary' => 'proprietary', 0, ); while ( my ($pattern, $license, $osi) = splice(@phrases, 0, 3) ) { $pattern =~ s#\s+#\\s+#gs; if ( $license_text =~ /\b$pattern\b/i ) { return $license; } } return ''; } sub license_from { my $self = shift; if (my $license=_extract_license(Module::Install::_read($_[0]))) { $self->license($license); } else { warn "Cannot determine license info from $_[0]\n"; return 'unknown'; } } sub _extract_bugtracker { my @links = $_[0] =~ m#L<( https?\Q://rt.cpan.org/\E[^>]+| https?\Q://github.com/\E[\w_]+/[\w_]+/issues| https?\Q://code.google.com/p/\E[\w_\-]+/issues/list )>#gx; my %links; @links{@links}=(); @links=keys %links; return @links; } sub bugtracker_from { my $self = shift; my $content = Module::Install::_read($_[0]); my @links = _extract_bugtracker($content); unless ( @links ) { warn "Cannot determine bugtracker info from $_[0]\n"; return 0; } if ( @links > 1 ) { warn "Found more than one bugtracker link in $_[0]\n"; return 0; } # Set the bugtracker bugtracker( $links[0] ); return 1; } sub requires_from { my $self = shift; my $content = Module::Install::_readperl($_[0]); my @requires = $content =~ m/^use\s+([^\W\d]\w*(?:::\w+)*)\s+(v?[\d\.]+)/mg; while ( @requires ) { my $module = shift @requires; my $version = shift @requires; $self->requires( $module => $version ); } } sub test_requires_from { my $self = shift; my $content = Module::Install::_readperl($_[0]); my @requires = $content =~ m/^use\s+([^\W\d]\w*(?:::\w+)*)\s+([\d\.]+)/mg; while ( @requires ) { my $module = shift @requires; my $version = shift @requires; $self->test_requires( $module => $version ); } } # Convert triple-part versions (eg, 5.6.1 or 5.8.9) to # numbers (eg, 5.006001 or 5.008009). # Also, convert double-part versions (eg, 5.8) sub _perl_version { my $v = $_[-1]; $v =~ s/^([1-9])\.([1-9]\d?\d?)$/sprintf("%d.%03d",$1,$2)/e; $v =~ s/^([1-9])\.([1-9]\d?\d?)\.(0|[1-9]\d?\d?)$/sprintf("%d.%03d%03d",$1,$2,$3 || 0)/e; $v =~ s/(\.\d\d\d)000$/$1/; $v =~ s/_.+$//; if ( ref($v) ) { # Numify $v = $v + 0; } return $v; } sub add_metadata { my $self = shift; my %hash = @_; for my $key (keys %hash) { warn "add_metadata: $key is not prefixed with 'x_'.\n" . "Use appopriate function to add non-private metadata.\n" unless $key =~ /^x_/; $self->{values}->{$key} = $hash{$key}; } } ###################################################################### # MYMETA Support sub WriteMyMeta { die "WriteMyMeta has been deprecated"; } sub write_mymeta_yaml { my $self = shift; # We need YAML::Tiny to write the MYMETA.yml file unless ( eval { require YAML::Tiny; 1; } ) { return 1; } # Generate the data my $meta = $self->_write_mymeta_data or return 1; # Save as the MYMETA.yml file print "Writing MYMETA.yml\n"; YAML::Tiny::DumpFile('MYMETA.yml', $meta); } sub write_mymeta_json { my $self = shift; # We need JSON to write the MYMETA.json file unless ( eval { require JSON; 1; } ) { return 1; } # Generate the data my $meta = $self->_write_mymeta_data or return 1; # Save as the MYMETA.yml file print "Writing MYMETA.json\n"; Module::Install::_write( 'MYMETA.json', JSON->new->pretty(1)->canonical->encode($meta), ); } sub _write_mymeta_data { my $self = shift; # If there's no existing META.yml there is nothing we can do return undef unless -f 'META.yml'; # We need Parse::CPAN::Meta to load the file unless ( eval { require Parse::CPAN::Meta; 1; } ) { return undef; } # Merge the perl version into the dependencies my $val = $self->Meta->{values}; my $perl = delete $val->{perl_version}; if ( $perl ) { $val->{requires} ||= []; my $requires = $val->{requires}; # Canonize to three-dot version after Perl 5.6 if ( $perl >= 5.006 ) { $perl =~ s{^(\d+)\.(\d\d\d)(\d*)}{join('.', $1, int($2||0), int($3||0))}e } unshift @$requires, [ perl => $perl ]; } # Load the advisory META.yml file my @yaml = Parse::CPAN::Meta::LoadFile('META.yml'); my $meta = $yaml[0]; # Overwrite the non-configure dependency hashes delete $meta->{requires}; delete $meta->{build_requires}; delete $meta->{recommends}; if ( exists $val->{requires} ) { $meta->{requires} = { map { @$_ } @{ $val->{requires} } }; } if ( exists $val->{build_requires} ) { $meta->{build_requires} = { map { @$_ } @{ $val->{build_requires} } }; } return $meta; } 1; Time-ParseDate-2026.0219/inc/Module/Install/Win32.pm000644 000765 000024 00000003403 15150357775 022255 0ustar00jbrandtstaff000000 000000 #line 1 package Module::Install::Win32; use strict; use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.21'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } # determine if the user needs nmake, and download it if needed sub check_nmake { my $self = shift; $self->load('can_run'); $self->load('get_file'); require Config; return unless ( $^O eq 'MSWin32' and $Config::Config{make} and $Config::Config{make} =~ /^nmake\b/i and ! $self->can_run('nmake') ); print "The required 'nmake' executable not found, fetching it...\n"; require File::Basename; my $rv = $self->get_file( url => 'http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe', ftp_url => 'ftp://ftp.microsoft.com/Softlib/MSLFILES/Nmake15.exe', local_dir => File::Basename::dirname($^X), size => 51928, run => 'Nmake15.exe /o > nul', check_for => 'Nmake.exe', remove => 1, ); die <<'END_MESSAGE' unless $rv; ------------------------------------------------------------------------------- Since you are using Microsoft Windows, you will need the 'nmake' utility before installation. It's available at: http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe or ftp://ftp.microsoft.com/Softlib/MSLFILES/Nmake15.exe Please download the file manually, save it to a directory in %PATH% (e.g. C:\WINDOWS\COMMAND\), then launch the MS-DOS command line shell, "cd" to that directory, and run "Nmake15.exe" from there; that will create the 'nmake.exe' file needed by this module. You may then resume the installation process described in README. ------------------------------------------------------------------------------- END_MESSAGE } 1; Time-ParseDate-2026.0219/inc/Module/Install/ReadmeFromPod.pm000644 000765 000024 00000010164 15150357775 024041 0ustar00jbrandtstaff000000 000000 #line 1 package Module::Install::ReadmeFromPod; use 5.006; use strict; use warnings; use base qw(Module::Install::Base); use vars qw($VERSION); $VERSION = '0.30'; { # these aren't defined until after _require_admin is run, so # define them so prototypes are available during compilation. sub io; sub capture(&;@); #line 28 my $done = 0; sub _require_admin { # do this once to avoid redefinition warnings from IO::All return if $done; require IO::All; IO::All->import( '-binary' ); require Capture::Tiny; Capture::Tiny->import ( 'capture' ); return; } } sub readme_from { my $self = shift; return unless $self->is_admin; _require_admin; # Input file my $in_file = shift || $self->_all_from or die "Can't determine file to make readme_from"; # Get optional arguments my ($clean, $format, $out_file, $options); my $args = shift; if ( ref $args ) { # Arguments are in a hashref if ( ref($args) ne 'HASH' ) { die "Expected a hashref but got a ".ref($args)."\n"; } else { $clean = $args->{'clean'}; $format = $args->{'format'}; $out_file = $args->{'output_file'}; $options = $args->{'options'}; } } else { # Arguments are in a list $clean = $args; $format = shift; $out_file = shift; $options = \@_; } # Default values; $clean ||= 0; $format ||= 'txt'; # Generate README print "readme_from $in_file to $format\n"; if ($format =~ m/te?xt/) { $out_file = $self->_readme_txt($in_file, $out_file, $options); } elsif ($format =~ m/html?/) { $out_file = $self->_readme_htm($in_file, $out_file, $options); } elsif ($format eq 'man') { $out_file = $self->_readme_man($in_file, $out_file, $options); } elsif ($format eq 'md') { $out_file = $self->_readme_md($in_file, $out_file, $options); } elsif ($format eq 'pdf') { $out_file = $self->_readme_pdf($in_file, $out_file, $options); } if ($clean) { $self->clean_files($out_file); } return 1; } sub _readme_txt { my ($self, $in_file, $out_file, $options) = @_; $out_file ||= 'README'; require Pod::Text; my $parser = Pod::Text->new( @$options ); my $io = io->file($out_file)->open(">"); my $out_fh = $io->io_handle; $parser->output_fh( *$out_fh ); $parser->parse_file( $in_file ); return $out_file; } sub _readme_htm { my ($self, $in_file, $out_file, $options) = @_; $out_file ||= 'README.htm'; require Pod::Html; my ($o) = capture { Pod::Html::pod2html( "--infile=$in_file", "--outfile=-", @$options, ); }; io->file($out_file)->print($o); # Remove temporary files if needed for my $file ('pod2htmd.tmp', 'pod2htmi.tmp') { if (-e $file) { unlink $file or warn "Warning: Could not remove file '$file'.\n$!\n"; } } return $out_file; } sub _readme_man { my ($self, $in_file, $out_file, $options) = @_; $out_file ||= 'README.1'; require Pod::Man; my $parser = Pod::Man->new( @$options ); my $io = io->file($out_file)->open(">"); my $out_fh = $io->io_handle; $parser->output_fh( *$out_fh ); $parser->parse_file( $in_file ); return $out_file; } sub _readme_pdf { my ($self, $in_file, $out_file, $options) = @_; $out_file ||= 'README.pdf'; eval { require App::pod2pdf; } or die "Could not generate $out_file because pod2pdf could not be found\n"; my $parser = App::pod2pdf->new( @$options ); $parser->parse_from_file($in_file); my ($o) = capture { $parser->output }; io->file($out_file)->print($o); return $out_file; } sub _readme_md { my ($self, $in_file, $out_file, $options) = @_; $out_file ||= 'README.md'; require Pod::Markdown; my $parser = Pod::Markdown->new( @$options ); my $io = io->file($out_file)->open(">"); my $out_fh = $io->io_handle; $parser->output_fh( *$out_fh ); $parser->parse_file( $in_file ); return $out_file; } sub _all_from { my $self = shift; return unless $self->admin->{extensions}; my ($metadata) = grep { ref($_) eq 'Module::Install::Metadata'; } @{$self->admin->{extensions}}; return unless $metadata; return $metadata->{values}{all_from} || ''; } 'Readme!'; __END__ #line 316 Time-ParseDate-2026.0219/inc/Module/Install/WriteAll.pm000644 000765 000024 00000002376 15150357775 023106 0ustar00jbrandtstaff000000 000000 #line 1 package Module::Install::WriteAll; use strict; use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.21'; @ISA = qw{Module::Install::Base}; $ISCORE = 1; } sub WriteAll { my $self = shift; my %args = ( meta => 1, sign => 0, inline => 0, check_nmake => 1, @_, ); $self->sign(1) if $args{sign}; $self->admin->WriteAll(%args) if $self->is_admin; $self->check_nmake if $args{check_nmake}; unless ( $self->makemaker_args->{PL_FILES} ) { # XXX: This still may be a bit over-defensive... unless ($self->makemaker(6.25)) { $self->makemaker_args( PL_FILES => {} ) if -f 'Build.PL'; } } # Until ExtUtils::MakeMaker support MYMETA.yml, make sure # we clean it up properly ourself. $self->realclean_files('MYMETA.yml'); if ( $args{inline} ) { $self->Inline->write; } else { $self->Makefile->write; } # The Makefile write process adds a couple of dependencies, # so write the META.yml files after the Makefile. if ( $args{meta} ) { $self->Meta->write; } # Experimental support for MYMETA if ( $ENV{X_MYMETA} ) { if ( $ENV{X_MYMETA} eq 'JSON' ) { $self->Meta->write_mymeta_json; } else { $self->Meta->write_mymeta_yaml; } } return 1; } 1; Time-ParseDate-2026.0219/inc/Module/Install/Can.pm000644 000765 000024 00000006405 15150357775 022061 0ustar00jbrandtstaff000000 000000 #line 1 package Module::Install::Can; use strict; use Config (); use ExtUtils::MakeMaker (); use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.21'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } # check if we can load some module ### Upgrade this to not have to load the module if possible sub can_use { my ($self, $mod, $ver) = @_; $mod =~ s{::|\\}{/}g; $mod .= '.pm' unless $mod =~ /\.pm$/i; my $pkg = $mod; $pkg =~ s{/}{::}g; $pkg =~ s{\.pm$}{}i; local $@; eval { require $mod; $pkg->VERSION($ver || 0); 1 }; } # Check if we can run some command sub can_run { my ($self, $cmd) = @_; my $_cmd = $cmd; return $_cmd if (-x $_cmd or $_cmd = MM->maybe_command($_cmd)); for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') { next if $dir eq ''; require File::Spec; my $abs = File::Spec->catfile($dir, $cmd); return $abs if (-x $abs or $abs = MM->maybe_command($abs)); } return; } # Can our C compiler environment build XS files sub can_xs { my $self = shift; # Ensure we have the CBuilder module $self->configure_requires( 'ExtUtils::CBuilder' => 0.27 ); # Do we have the configure_requires checker? local $@; eval "require ExtUtils::CBuilder;"; if ( $@ ) { # They don't obey configure_requires, so it is # someone old and delicate. Try to avoid hurting # them by falling back to an older simpler test. return $self->can_cc(); } # Do we have a working C compiler my $builder = ExtUtils::CBuilder->new( quiet => 1, ); unless ( $builder->have_compiler ) { # No working C compiler return 0; } # Write a C file representative of what XS becomes require File::Temp; my ( $FH, $tmpfile ) = File::Temp::tempfile( "compilexs-XXXXX", SUFFIX => '.c', ); binmode $FH; print $FH <<'END_C'; #include "EXTERN.h" #include "perl.h" #include "XSUB.h" int main(int argc, char **argv) { return 0; } int boot_sanexs() { return 1; } END_C close $FH; # Can the C compiler access the same headers XS does my @libs = (); my $object = undef; eval { local $^W = 0; $object = $builder->compile( source => $tmpfile, ); @libs = $builder->link( objects => $object, module_name => 'sanexs', ); }; my $result = $@ ? 0 : 1; # Clean up all the build files foreach ( $tmpfile, $object, @libs ) { next unless defined $_; 1 while unlink; } return $result; } # Can we locate a (the) C compiler sub can_cc { my $self = shift; if ($^O eq 'VMS') { require ExtUtils::CBuilder; my $builder = ExtUtils::CBuilder->new( quiet => 1, ); return $builder->have_compiler; } my @chunks = split(/ /, $Config::Config{cc}) or return; # $Config{cc} may contain args; try to find out the program part while (@chunks) { return $self->can_run("@chunks") || (pop(@chunks), next); } return; } # Fix Cygwin bug on maybe_command(); if ( $^O eq 'cygwin' ) { require ExtUtils::MM_Cygwin; require ExtUtils::MM_Win32; if ( ! defined(&ExtUtils::MM_Cygwin::maybe_command) ) { *ExtUtils::MM_Cygwin::maybe_command = sub { my ($self, $file) = @_; if ($file =~ m{^/cygdrive/}i and ExtUtils::MM_Win32->can('maybe_command')) { ExtUtils::MM_Win32->maybe_command($file); } else { ExtUtils::MM_Unix->maybe_command($file); } } } } 1; __END__ #line 245 Time-ParseDate-2026.0219/inc/Module/Install/Makefile.pm000644 000765 000024 00000027437 15150357775 023105 0ustar00jbrandtstaff000000 000000 #line 1 package Module::Install::Makefile; use strict 'vars'; use ExtUtils::MakeMaker (); use Module::Install::Base (); use Fcntl qw/:flock :seek/; use vars qw{$VERSION @ISA $ISCORE}; BEGIN { $VERSION = '1.21'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } sub Makefile { $_[0] } my %seen = (); sub prompt { shift; # Infinite loop protection my @c = caller(); if ( ++$seen{"$c[1]|$c[2]|$_[0]"} > 3 ) { die "Caught an potential prompt infinite loop ($c[1]|$c[2]|$_[0])"; } # In automated testing or non-interactive session, always use defaults if ( ($ENV{AUTOMATED_TESTING} or -! -t STDIN) and ! $ENV{PERL_MM_USE_DEFAULT} ) { local $ENV{PERL_MM_USE_DEFAULT} = 1; goto &ExtUtils::MakeMaker::prompt; } else { goto &ExtUtils::MakeMaker::prompt; } } # Store a cleaned up version of the MakeMaker version, # since we need to behave differently in a variety of # ways based on the MM version. my $makemaker = eval $ExtUtils::MakeMaker::VERSION; # If we are passed a param, do a "newer than" comparison. # Otherwise, just return the MakeMaker version. sub makemaker { ( @_ < 2 or $makemaker >= eval($_[1]) ) ? $makemaker : 0 } # Ripped from ExtUtils::MakeMaker 6.56, and slightly modified # as we only need to know here whether the attribute is an array # or a hash or something else (which may or may not be appendable). my %makemaker_argtype = ( C => 'ARRAY', CONFIG => 'ARRAY', # CONFIGURE => 'CODE', # ignore DIR => 'ARRAY', DL_FUNCS => 'HASH', DL_VARS => 'ARRAY', EXCLUDE_EXT => 'ARRAY', EXE_FILES => 'ARRAY', FUNCLIST => 'ARRAY', H => 'ARRAY', IMPORTS => 'HASH', INCLUDE_EXT => 'ARRAY', LIBS => 'ARRAY', # ignore '' MAN1PODS => 'HASH', MAN3PODS => 'HASH', META_ADD => 'HASH', META_MERGE => 'HASH', PL_FILES => 'HASH', PM => 'HASH', PMLIBDIRS => 'ARRAY', PMLIBPARENTDIRS => 'ARRAY', PREREQ_PM => 'HASH', CONFIGURE_REQUIRES => 'HASH', SKIP => 'ARRAY', TYPEMAPS => 'ARRAY', XS => 'HASH', # VERSION => ['version',''], # ignore # _KEEP_AFTER_FLUSH => '', clean => 'HASH', depend => 'HASH', dist => 'HASH', dynamic_lib=> 'HASH', linkext => 'HASH', macro => 'HASH', postamble => 'HASH', realclean => 'HASH', test => 'HASH', tool_autosplit => 'HASH', # special cases where you can use makemaker_append CCFLAGS => 'APPENDABLE', DEFINE => 'APPENDABLE', INC => 'APPENDABLE', LDDLFLAGS => 'APPENDABLE', LDFROM => 'APPENDABLE', ); sub makemaker_args { my ($self, %new_args) = @_; my $args = ( $self->{makemaker_args} ||= {} ); foreach my $key (keys %new_args) { if ($makemaker_argtype{$key}) { if ($makemaker_argtype{$key} eq 'ARRAY') { $args->{$key} = [] unless defined $args->{$key}; unless (ref $args->{$key} eq 'ARRAY') { $args->{$key} = [$args->{$key}] } push @{$args->{$key}}, ref $new_args{$key} eq 'ARRAY' ? @{$new_args{$key}} : $new_args{$key}; } elsif ($makemaker_argtype{$key} eq 'HASH') { $args->{$key} = {} unless defined $args->{$key}; foreach my $skey (keys %{ $new_args{$key} }) { $args->{$key}{$skey} = $new_args{$key}{$skey}; } } elsif ($makemaker_argtype{$key} eq 'APPENDABLE') { $self->makemaker_append($key => $new_args{$key}); } } else { if (defined $args->{$key}) { warn qq{MakeMaker attribute "$key" is overriden; use "makemaker_append" to append values\n}; } $args->{$key} = $new_args{$key}; } } return $args; } # For mm args that take multiple space-separated args, # append an argument to the current list. sub makemaker_append { my $self = shift; my $name = shift; my $args = $self->makemaker_args; $args->{$name} = defined $args->{$name} ? join( ' ', $args->{$name}, @_ ) : join( ' ', @_ ); } sub build_subdirs { my $self = shift; my $subdirs = $self->makemaker_args->{DIR} ||= []; for my $subdir (@_) { push @$subdirs, $subdir; } } sub clean_files { my $self = shift; my $clean = $self->makemaker_args->{clean} ||= {}; %$clean = ( %$clean, FILES => join ' ', grep { length $_ } ($clean->{FILES} || (), @_), ); } sub realclean_files { my $self = shift; my $realclean = $self->makemaker_args->{realclean} ||= {}; %$realclean = ( %$realclean, FILES => join ' ', grep { length $_ } ($realclean->{FILES} || (), @_), ); } sub libs { my $self = shift; my $libs = ref $_[0] ? shift : [ shift ]; $self->makemaker_args( LIBS => $libs ); } sub inc { my $self = shift; $self->makemaker_args( INC => shift ); } sub _wanted_t { } sub tests_recursive { my $self = shift; my $dir = shift || 't'; unless ( -d $dir ) { die "tests_recursive dir '$dir' does not exist"; } my %tests = map { $_ => 1 } split / /, ($self->tests || ''); require File::Find; File::Find::find( sub { /\.t$/ and -f $_ and $tests{"$File::Find::dir/*.t"} = 1 }, $dir ); $self->tests( join ' ', sort keys %tests ); } sub write { my $self = shift; die "&Makefile->write() takes no arguments\n" if @_; # Check the current Perl version my $perl_version = $self->perl_version; if ( $perl_version ) { eval "use $perl_version; 1" or die "ERROR: perl: Version $] is installed, " . "but we need version >= $perl_version"; } # Make sure we have a new enough MakeMaker require ExtUtils::MakeMaker; if ( $perl_version and $self->_cmp($perl_version, '5.006') >= 0 ) { # This previous attempted to inherit the version of # ExtUtils::MakeMaker in use by the module author, but this # was found to be untenable as some authors build releases # using future dev versions of EU:MM that nobody else has. # Instead, #toolchain suggests we use 6.59 which is the most # stable version on CPAN at time of writing and is, to quote # ribasushi, "not terminally fucked, > and tested enough". # TODO: We will now need to maintain this over time to push # the version up as new versions are released. $self->build_requires( 'ExtUtils::MakeMaker' => 6.59 ); $self->configure_requires( 'ExtUtils::MakeMaker' => 6.59 ); } else { # Allow legacy-compatibility with 5.005 by depending on the # most recent EU:MM that supported 5.005. $self->build_requires( 'ExtUtils::MakeMaker' => 6.36 ); $self->configure_requires( 'ExtUtils::MakeMaker' => 6.36 ); } # Generate the MakeMaker params my $args = $self->makemaker_args; $args->{DISTNAME} = $self->name; $args->{NAME} = $self->module_name || $self->name; $args->{NAME} =~ s/-/::/g; $args->{VERSION} = $self->version or die <<'EOT'; ERROR: Can't determine distribution version. Please specify it explicitly via 'version' in Makefile.PL, or set a valid $VERSION in a module, and provide its file path via 'version_from' (or 'all_from' if you prefer) in Makefile.PL. EOT if ( $self->tests ) { my @tests = split ' ', $self->tests; my %seen; $args->{test} = { TESTS => (join ' ', grep {!$seen{$_}++} @tests), }; } elsif ( $Module::Install::ExtraTests::use_extratests ) { # Module::Install::ExtraTests doesn't set $self->tests and does its own tests via harness. # So, just ignore our xt tests here. } elsif ( -d 'xt' and ($Module::Install::AUTHOR or $ENV{RELEASE_TESTING}) ) { $args->{test} = { TESTS => join( ' ', map { "$_/*.t" } grep { -d $_ } qw{ t xt } ), }; } if ( $] >= 5.005 ) { $args->{ABSTRACT} = $self->abstract; $args->{AUTHOR} = join ', ', @{$self->author || []}; } if ( $self->makemaker(6.10) ) { $args->{NO_META} = 1; #$args->{NO_MYMETA} = 1; } if ( $self->makemaker(6.17) and $self->sign ) { $args->{SIGN} = 1; } unless ( $self->is_admin ) { delete $args->{SIGN}; } if ( $self->makemaker(6.31) and $self->license ) { $args->{LICENSE} = $self->license; } my $prereq = ($args->{PREREQ_PM} ||= {}); %$prereq = ( %$prereq, map { @$_ } # flatten [module => version] map { @$_ } grep $_, ($self->requires) ); # Remove any reference to perl, PREREQ_PM doesn't support it delete $args->{PREREQ_PM}->{perl}; # Merge both kinds of requires into BUILD_REQUIRES my $build_prereq = ($args->{BUILD_REQUIRES} ||= {}); %$build_prereq = ( %$build_prereq, map { @$_ } # flatten [module => version] map { @$_ } grep $_, ($self->configure_requires, $self->build_requires) ); # Remove any reference to perl, BUILD_REQUIRES doesn't support it delete $args->{BUILD_REQUIRES}->{perl}; # Delete bundled dists from prereq_pm, add it to Makefile DIR my $subdirs = ($args->{DIR} || []); if ($self->bundles) { my %processed; foreach my $bundle (@{ $self->bundles }) { my ($mod_name, $dist_dir) = @$bundle; delete $prereq->{$mod_name}; $dist_dir = File::Basename::basename($dist_dir); # dir for building this module if (not exists $processed{$dist_dir}) { if (-d $dist_dir) { # List as sub-directory to be processed by make push @$subdirs, $dist_dir; } # Else do nothing: the module is already present on the system $processed{$dist_dir} = undef; } } } unless ( $self->makemaker('6.55_03') ) { %$prereq = (%$prereq,%$build_prereq); delete $args->{BUILD_REQUIRES}; } if ( my $perl_version = $self->perl_version ) { eval "use $perl_version; 1" or die "ERROR: perl: Version $] is installed, " . "but we need version >= $perl_version"; if ( $self->makemaker(6.48) ) { $args->{MIN_PERL_VERSION} = $perl_version; } } if ($self->installdirs) { warn qq{old INSTALLDIRS (probably set by makemaker_args) is overriden by installdirs\n} if $args->{INSTALLDIRS}; $args->{INSTALLDIRS} = $self->installdirs; } my %args = map { ( $_ => $args->{$_} ) } grep {defined($args->{$_} ) } keys %$args; my $user_preop = delete $args{dist}->{PREOP}; if ( my $preop = $self->admin->preop($user_preop) ) { foreach my $key ( keys %$preop ) { $args{dist}->{$key} = $preop->{$key}; } } my $mm = ExtUtils::MakeMaker::WriteMakefile(%args); $self->fix_up_makefile($mm->{FIRST_MAKEFILE} || 'Makefile'); } sub fix_up_makefile { my $self = shift; my $makefile_name = shift; my $top_class = ref($self->_top) || ''; my $top_version = $self->_top->VERSION || ''; my $preamble = $self->preamble ? "# Preamble by $top_class $top_version\n" . $self->preamble : ''; my $postamble = "# Postamble by $top_class $top_version\n" . ($self->postamble || ''); local *MAKEFILE; open MAKEFILE, "+< $makefile_name" or die "fix_up_makefile: Couldn't open $makefile_name: $!"; eval { flock MAKEFILE, LOCK_EX }; my $makefile = do { local $/; }; $makefile =~ s/\b(test_harness\(\$\(TEST_VERBOSE\), )/$1'inc', /; $makefile =~ s/( -I\$\(INST_ARCHLIB\))/ -Iinc$1/g; $makefile =~ s/( "-I\$\(INST_LIB\)")/ "-Iinc"$1/g; $makefile =~ s/^(FULLPERL = .*)/$1 "-Iinc"/m; $makefile =~ s/^(PERL = .*)/$1 "-Iinc"/m; # Module::Install will never be used to build the Core Perl # Sometimes PERL_LIB and PERL_ARCHLIB get written anyway, which breaks # PREFIX/PERL5LIB, and thus, install_share. Blank them if they exist $makefile =~ s/^PERL_LIB = .+/PERL_LIB =/m; #$makefile =~ s/^PERL_ARCHLIB = .+/PERL_ARCHLIB =/m; # Perl 5.005 mentions PERL_LIB explicitly, so we have to remove that as well. $makefile =~ s/(\"?)-I\$\(PERL_LIB\)\1//g; # XXX - This is currently unused; not sure if it breaks other MM-users # $makefile =~ s/^pm_to_blib\s+:\s+/pm_to_blib :: /mg; seek MAKEFILE, 0, SEEK_SET; truncate MAKEFILE, 0; print MAKEFILE "$preamble$makefile$postamble" or die $!; close MAKEFILE or die $!; 1; } sub preamble { my ($self, $text) = @_; $self->{preamble} = $text . $self->{preamble} if defined $text; $self->{preamble}; } sub postamble { my ($self, $text) = @_; $self->{postamble} ||= $self->admin->postamble; $self->{postamble} .= $text if defined $text; $self->{postamble} } 1; __END__ #line 544 Time-ParseDate-2026.0219/inc/Module/Install/Base.pm000644 000765 000024 00000002147 15150357775 022231 0ustar00jbrandtstaff000000 000000 #line 1 package Module::Install::Base; use strict 'vars'; use vars qw{$VERSION}; BEGIN { $VERSION = '1.21'; } # Suspend handler for "redefined" warnings BEGIN { my $w = $SIG{__WARN__}; $SIG{__WARN__} = sub { $w }; } #line 42 sub new { my $class = shift; unless ( defined &{"${class}::call"} ) { *{"${class}::call"} = sub { shift->_top->call(@_) }; } unless ( defined &{"${class}::load"} ) { *{"${class}::load"} = sub { shift->_top->load(@_) }; } bless { @_ }, $class; } #line 61 sub AUTOLOAD { local $@; my $func = eval { shift->_top->autoload } or return; goto &$func; } #line 75 sub _top { $_[0]->{_top}; } #line 90 sub admin { $_[0]->_top->{admin} or Module::Install::Base::FakeAdmin->new; } #line 106 sub is_admin { ! $_[0]->admin->isa('Module::Install::Base::FakeAdmin'); } sub DESTROY {} package Module::Install::Base::FakeAdmin; use vars qw{$VERSION}; BEGIN { $VERSION = $Module::Install::Base::VERSION; } my $fake; sub new { $fake ||= bless(\@_, $_[0]); } sub AUTOLOAD {} sub DESTROY {} # Restore warning handler BEGIN { $SIG{__WARN__} = $SIG{__WARN__}->(); } 1; #line 159