Subject: | Allow use of DateTime format 'datetime', i.e. 2009-08-13T12:57:23 |
The dates used assume a format like
2009/08/12
or
2009/08/12T13:57:10
DateTime uses a slightly different format, i.e
--
$ perl -MDateTime -le 'print DateTime->now->ymd'
2009-08-13
$ perl -MDateTime -le 'print DateTime->now->datetime'
2009-08-13T12:57:23
--
It is possible to use
--
$ perl -MDateTime -le 'print DateTime->now->ymd("/")'
2009/08/13
--
but that doesn't help with '->datetime'
Attached is a patch that copes with DateTime style dates and tests for
them (copied existing tests and amended all the datestrings)
Subject: | Graph-Timeline-1.4_DateTime.patch |
Only in Graph-Timeline-1.4: blib
Only in Graph-Timeline-1.4/examples: test_diagonal1.map
Only in Graph-Timeline-1.4/examples: test_diagonal1.png
Only in Graph-Timeline-1.4/examples: test_diagonal2.map
Only in Graph-Timeline-1.4/examples: test_diagonal2.png
Only in Graph-Timeline-1.4/examples: test_timeline_01.png
Only in Graph-Timeline-1.4/examples: test_timeline_02.png
Only in Graph-Timeline-1.4/examples: test_timeline_03.png
Only in Graph-Timeline-1.4/examples: test_timeline_04.png
Only in Graph-Timeline-1.4/examples: test_timeline_05.png
diff -ur Graph-Timeline-1.4.orig/lib/Graph/Timeline/DiagonalGD.pm Graph-Timeline-1.4/lib/Graph/Timeline/DiagonalGD.pm
--- Graph-Timeline-1.4.orig/lib/Graph/Timeline/DiagonalGD.pm 2007-06-20 20:58:35.000000000 +0100
+++ Graph-Timeline-1.4/lib/Graph/Timeline/DiagonalGD.pm 2009-08-13 11:16:47.000000000 +0100
@@ -250,9 +250,9 @@
my ( $date_date, $date_time ) = split( 'T', $date );
my ( $base_date, $base_time ) = split( 'T', $base );
- my ( $dyear, $dmonth, $dday ) = split( '\/', $date_date );
+ my ( $dyear, $dmonth, $dday ) = split( '[\/-]', $date_date );
my ( $dhour, $dminute, $dsecond ) = split( ':', $date_time );
- my ( $byear, $bmonth, $bday ) = split( '\/', $base_date );
+ my ( $byear, $bmonth, $bday ) = split( '[\/-]', $base_date );
my ( $bhour, $bminute, $bsecond ) = split( ':', $base_time );
my ( $D_y, $D_m, $D_d, $Dh, $Dm, $Ds ) = Date::Calc::Delta_YMDHMS( $byear, $bmonth, $bday, $bhour, $bminute, $bsecond, $dyear, $dmonth, $dday, $dhour, $dminute, $dsecond );
diff -ur Graph-Timeline-1.4.orig/lib/Graph/Timeline/GD.pm Graph-Timeline-1.4/lib/Graph/Timeline/GD.pm
--- Graph-Timeline-1.4.orig/lib/Graph/Timeline/GD.pm 2007-06-20 20:59:01.000000000 +0100
+++ Graph-Timeline-1.4/lib/Graph/Timeline/GD.pm 2009-08-13 11:17:28.000000000 +0100
@@ -293,8 +293,8 @@
return 0 if $record->{$start} eq $record->{$end};
- my ( $first_year, $first_month, $first_day ) = split( '\/', ( split( 'T', $record->{$start} ) )[0] );
- my ( $last_year, $last_month, $last_day ) = split( '\/', ( split( 'T', $record->{$end} ) )[0] );
+ my ( $first_year, $first_month, $first_day ) = split( '[\/-]', ( split( 'T', $record->{$start} ) )[0] );
+ my ( $last_year, $last_month, $last_day ) = split( '[\/-]', ( split( 'T', $record->{$end} ) )[0] );
# Calculate pixel width
@@ -323,8 +323,8 @@
sub _calc_start_x {
my ( $self, $start_graph, $start_interval, %years ) = @_;
- my ( $first_year, $first_month, $first_day ) = split( '\/', ( split( 'T', $start_graph ) )[0] );
- my ( $last_year, $last_month, $last_day ) = split( '\/', ( split( 'T', $start_interval ) )[0] );
+ my ( $first_year, $first_month, $first_day ) = split( '[\/-]', ( split( 'T', $start_graph ) )[0] );
+ my ( $last_year, $last_month, $last_day ) = split( '[\/-]', ( split( 'T', $start_interval ) )[0] );
my $x = 0;
@@ -350,8 +350,8 @@
$end = $record->{end} if $record->{end} gt $end;
}
- $start = ( split( '\/', $start ) )[0];
- $end = ( split( '\/', $end ) )[0];
+ $start = ( split( '[\/-]', $start ) )[0];
+ $end = ( split( '[\/-]', $end ) )[0];
return $start, $end;
}
diff -ur Graph-Timeline-1.4.orig/lib/Graph/Timeline.pm Graph-Timeline-1.4/lib/Graph/Timeline.pm
--- Graph-Timeline-1.4.orig/lib/Graph/Timeline.pm 2007-06-20 20:59:30.000000000 +0100
+++ Graph-Timeline-1.4/lib/Graph/Timeline.pm 2009-08-13 11:13:13.000000000 +0100
@@ -216,7 +216,7 @@
my ( $self, $date ) = @_;
my ( $date_part, $time_part ) = split( 'T', $date );
- my ( $year, $month, $day ) = split( '\/', $date_part );
+ my ( $year, $month, $day ) = split( '[\/-]', $date_part );
## Check the date first
@@ -274,7 +274,7 @@
my ( $self, $label, %record ) = @_;
my ( $date_part, $time_part ) = split( 'T', $record{$label} );
- my ( $year, $month, $day ) = split( '\/', $date_part );
+ my ( $year, $month, $day ) = split( '[\/-]', $date_part );
if ($day) {
$record{"${label}_start"} = $date_part;
Only in Graph-Timeline-1.4: Makefile
Only in Graph-Timeline-1.4: pm_to_blib
Only in Graph-Timeline-1.4/t: DiagnalGD2.t
Only in Graph-Timeline-1.4/t: render2.t