1use strict; 2use warnings; 3 4use XML::Atom::SimpleFeed; 5 6package XML::Atom::SimpleFeed; 7use Test::More tests => 14; 8 9my $bigbang = '<d>1970-01-01T00:00:00Z</d>'; 10 11is date_construct( d => 0 ), $bigbang, 'correct RFC 3339 for Unix times'; 12 13SKIP: { 14 skip 'missing Time::Piece', 2 unless eval { require Time::Piece }; 15 is date_construct( d => Time::Piece->gmtime(0) ), $bigbang, 'correct RFC 3339 for Time::Piece objects'; 16 is date_construct( d => Time::Piece->localtime(0) ), $bigbang, '... regardless of local timezone'; 17}; 18 19SKIP: { 20 skip 'missing DateTime', 2 unless eval { require DateTime }; 21 my @tz = map +( time_zone => $_ ), grep defined, eval { DateTime::TimeZone->new( name => 'local' ) }; 22 is date_construct( d => DateTime->from_epoch( epoch => 0 ) ), $bigbang, 'correct RFC 3339 for DateTime objects'; 23 is date_construct( d => DateTime->from_epoch( epoch => 0, @tz ) ), $bigbang, '... regardless of local timezone' if @tz; 24 skip 'failed DateTime::TimeZone detection', 1 unless @tz; 25}; 26 27SKIP: { 28 skip 'missing Time::Moment', 2 unless eval { require Time::Moment }; 29 my $tm = Time::Moment->from_epoch(0); 30 is date_construct( d => $tm ), $bigbang, 'correct RFC 3339 for Time::Moment objects'; 31 $tm = $tm->with_offset_same_instant( Time::Moment->now->offset ); 32 is date_construct( d => $tm ), $bigbang, '... regardless of local timezone'; 33}; 34 35SKIP: { 36 skip 'missing Panda::Date', 2 unless eval { require Panda::Date }; 37 is date_construct( d => Panda::Date->new(0, 'UTC') ), $bigbang, 'correct RFC 3339 for Class::Date objects'; 38 is date_construct( d => Panda::Date->new(0) ), $bigbang, '... regardless of local timezone'; 39}; 40 41SKIP: { 42 skip 'missing Class::Date', 2 unless eval { require Class::Date }; 43 is date_construct( d => Class::Date::gmdate('00') ), $bigbang, 'correct RFC 3339 for Class::Date objects'; 44 is date_construct( d => Class::Date::localdate('00') ), $bigbang, '... regardless of local timezone'; 45}; 46 47SKIP: { 48 skip 'missing Time::Object', 2 unless eval { require Time::Object }; 49 is date_construct( d => Time::Object::gmtime(0) ), $bigbang, 'correct RFC 3339 for Time::Object objects'; 50 is date_construct( d => Time::Object::localtime(0) ), $bigbang, '... regardless of local timezone'; 51}; 52 53SKIP: { 54 skip 'missing Time::Date', 1 unless eval { require Time::Date; Time::Date->VERSION('0.05') }; 55 is date_construct( d => Time::Date->new_epoch(0) ), $bigbang, 'correct RFC 3339 for Time::Date objects'; 56}; 57