Subject: | Now way to set epoch |
Right now it's impossible to define the epoch that's used. This isn't
necessarily useful unless you have a machine with a time that is
differnt from another machine on the same network, or you pull your time
from another source, such as database, etc.
Because of this I've made some very minor backwards compatible
modifications to str2time() to accept a different initial argument.
Attached is the patch to do this.
-cf
Subject: | add-time.txt |
--- lib/Date/Parse.pm 2011-01-12 00:57:56.000000000 -0700
+++ lib/Date/Parse.pm 2011-01-12 01:15:59.000000000 -0700
@@ -15,7 +15,7 @@
@ISA = qw(Exporter);
@EXPORT = qw(&strtotime &str2time &strptime);
-$VERSION = "2.30";
+$VERSION = "2.31";
my %month = (
january => 0,
@@ -228,13 +228,21 @@
sub str2time
{
+ my $T;
+ if(ref($_[0]) eq 'ARRAY'){
+ $T = $_[0];
+ ($_[0], $T) = @$T;
+ } else {
+ $T = time();
+ }
+
my @t = strptime(@_);
return undef
unless @t;
my($ss,$mm,$hh,$day,$month,$year,$zone) = @t;
- my @lt = localtime(time);
+ my @lt = localtime($T);
$hh ||= 0;
$mm ||= 0;
@@ -314,6 +322,10 @@
C<ZONE>, if given, specifies the timezone to assume when parsing if the
date string does not specify a timezone.
+B<OPTIONALLY> call C<str2time> with C<DATE> argument encapsulated in a two element
+array reference, with the first element being the standard C<DATE> string and the
+second being epoch time, (normally provided by C<time>)
+
=item strptime(DATE [, ZONE])
C<strptime> takes the same arguments as str2time but returns an array of