Permalink
Browse files

move to DateTime::Format::ISO8601 from DateTimeX::Easy because timezo…

…nes do not work in the latter
  • Loading branch information...
1 parent c51b90d commit a87d1efe071b4247c1f9c5bdf4490d4aa4793b41 @2shortplanks committed May 30, 2012
Showing with 39 additions and 13 deletions.
  1. +5 −5 Makefile.PL
  2. +14 −6 lib/Test/Recent.pm
  3. +9 −1 t/01owa.t
  4. +11 −1 t/02test.t
View
@@ -3,11 +3,11 @@ use inc::Module::Install;
name 'Test-Recent';
all_from 'lib/Test/Recent.pm';
-requires 'DateTime' => 0;
-requires 'DateTimeX::Easy' => 0;
-requires 'Time::Duration::Parse' => 0;
-requires 'Test::Builder' => 0;
-requires 'Scalar::Util' => 0;
+requires 'DateTime' => 0;
+requires 'DateTime::Format::ISO8601' => 0;
+requires 'Time::Duration::Parse' => 0;
+requires 'Test::Builder' => 0;
+requires 'Scalar::Util' => 0;
# T::B::T before 0.09 breaks with modern perls
build_requires 'Test::Builder::Tester' => 0.09;
View
@@ -5,23 +5,29 @@ use strict;
use Test::Builder::Tester;
use DateTime;
-use DateTimeX::Easy qw(datetime);
use Time::Duration::Parse qw(parse_duration);
+use DateTime::Format::ISO8601;
use Scalar::Util qw(blessed);
#use Smart::Comments;
use vars qw(@EXPORT_OK $VERSION $OverridedNowForTesting);
-$VERSION = "1.01";
+$VERSION = "2.00";
my $tester = Test::Builder->new();
+sub _datetime($) {
+ my $str = shift;
+ return $str if blessed $str && $str->isa("DateTime");
+ return eval { DateTime::Format::ISO8601->parse_datetime( $str ) }; ## no critic (RequireCheckingReturnValueOfEval)
+}
+
sub occured_within_ago($$) {
my $value = shift;
return unless defined $value;
- my $time = datetime($value);
+ my $time = _datetime($value);
return unless defined $time;
my $duration = shift;
@@ -83,8 +89,10 @@ Test::Recent - check a time is recent
=head1 DESCRIPTION
-Simple module to check things happened recently. Uses DateTimeX::Easy and
-Time::Duration::Parse do parse the times and durations.
+Simple module to check things happened recently. Uses DateTime::Format::ISO8601
+and Time::Duration::Parse to parse the times and durations (older versions of
+this module used DateTimeX::Easy because that module didn't handle iso
+timezones very well.)
=head2 Functions
@@ -132,7 +140,7 @@ L<http://github.com/2shortplanks/Test-Recent>
=head1 SEE ALSO
-L<DateTimeX::Easy>, L<Time::Duration::Parse>
+L<DateTime::Format::ISO8601>, L<Time::Duration::Parse>
=cut
View
@@ -9,7 +9,15 @@ use Test::MockTime qw(set_absolute_time);
ok(defined &occured_within_ago, "exported");
# now is not now
-my $now = DateTimeX::Easy->parse('2012-05-23T10:36:30Z');
+my $now = DateTime->new(
+ year => '2012',
+ month => '05',
+ day => '23',
+ hour => '10',
+ minute => '36',
+ second => '30',
+ time_zone => 'Z',
+);
# manually set the clock
$Test::Recent::OverridedNowForTesting = $now;
View
@@ -9,7 +9,17 @@ use Test::Builder::Tester;
ok(defined &recent, "exported");
# now is not now
-my $now = DateTimeX::Easy->parse('2012-05-23T10:36:30Z');
+
+# now is not now
+my $now = DateTime->new(
+ year => '2012',
+ month => '05',
+ day => '23',
+ hour => '10',
+ minute => '36',
+ second => '30',
+ time_zone => 'Z',
+);
# manually set the clock
$Test::Recent::OverridedNowForTesting = $now;

0 comments on commit a87d1ef

Please sign in to comment.