Test::Recent - check a time is recent
use Test::More; use Test::Recent qw(recent); # check things happened in the last ten seconds recent DateTime->now, "now is recent!"; recent "2012-12-23 00:00:00", "end of mayan calendar happened recently?"; # check things happened in the last hour recent "2012-12-23 00:00:00", DateTime::Duration->new( hours => 1 ), "mayan"; recent "2012-12-23 00:00:00", "1 hour", "mayan"
Simple module to check things happened recently.
These are exported on demand or may be called fully qualified
Tests (using the Test::Builder framework) if the time occured within the duration ago from the current time. If no duration is passed, ten seconds is assumed.
Returns true if and only if the time occured within the duration ago from the current time.
This module supports the following things being passed in as a date and time:
i.e. anything that DateTime::Format::ISO8601 can parse
i.e. something of the form YYYY-MM-DD HH:MM:SS.ssssss+TZ
YYYY-MM-DD HH:MM:SS.ssssss+TZ
Older verions of this module used DateTimeX::Easy to parse the datetime, but this proved to be unreliable.
Written by Mark Fowler <mark@twoshortplanks.com>
Copyright OmniTI 2012. All Rights Rerserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Bugs should be reported via this distribution's CPAN RT queue. This can be found at https://rt.cpan.org/Dist/Display.html?Test-Recent
You can also address issues by forking this distribution on github and sending pull requests. It can be found at http://github.com/2shortplanks/Test-Recent
In order not to depend on another DateTime library, this module converts postgres style TIMESTAMP WITH TIME ZONE by using a regular expression and simply ignoring microseconds. This potentially introduces a one second inaccuracy in the recent handling.
DateTime::Format::ISO8601, Time::Duration::Parse
To install Test::Recent, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::Recent
CPAN shell
perl -MCPAN -e shell install Test::Recent
For more information on module installation, please visit the detailed CPAN module installation guide.