Astro-App-Satpass2

 view release on metacpan or  search on metacpan

t/parse_time_iso8601.t  view on Meta::CPAN

	call_m( parse => 'today 9:30Z',
	    any_greg_time_gm( 0, 30, 9, 1, 6, 2009 ),
	    q{Parse ISO-8601 'today 9:30Z'} );

	call_m( parse => 'tomorrow Z',
	    any_greg_time_gm( 0, 0, 0, 2, 6, 2009 ),
	    q{Parse ISO-8601 'tomorrow Z'} );

	call_m( parse => 'tomorrow 9:30Z',
	    any_greg_time_gm( 0, 30, 9, 2, 6, 2009 ),
	    q{Parse ISO-8601 'tomorrow 9:30Z'} );

	restore_time();

	set_fixed_time( any_greg_time_local( 0, 0, 6, 1, 6, 2009 ) );

	call_m( parse => 'yesterday',
	    any_greg_time_local( 0, 0, 0, 30, 5, 2009 ),
	    q{Parse ISO-8601 'yesterday'} );

	call_m( parse => 'yesterday 9:30',
	    any_greg_time_local( 0, 30, 9, 30, 5, 2009 ),
	    q{Parse ISO-8601 'yesterday 9:30'} );

	call_m( parse => 'today',
	    any_greg_time_local( 0, 0, 0, 1, 6, 2009 ),
	    q{Parse ISO-8601 'today'} );

	call_m( parse => 'today 9:30',
	    any_greg_time_local( 0, 30, 9, 1, 6, 2009 ),
	    q{Parse ISO-8601 'today 9:30'} );

	call_m( parse => 'tomorrow',
	    any_greg_time_local( 0, 0, 0, 2, 6, 2009 ),
	    q{Parse ISO-8601 'tomorrow'} );

	call_m( parse => 'tomorrow 9:30',
	    any_greg_time_local( 0, 30, 9, 2, 6, 2009 ),
	    q{Parse ISO-8601 'tomorrow 9:30'} );

	restore_time();

    } else {

	skip 'Unable to load Test::MockTime', $tests;

    }

}

SKIP: {
    my $tests = 5;

    load_or_skip( 'DateTime', $tests );

    note <<'EOD';

We only do the following if DateTime can be loaded, because Time::Local
does strange things with long-past dates.

Yes, we're using the Gregorian calendar for dates that really should be
Julian, but for the moment we're stuck with that.

EOD

    my $dt = DateTime->new(	# Battle of Hastings
	year	=> 1066,
	month	=> 10,
	day	=> 14,
	time_zone	=> 'UTC',
    );

    call_m( parse => '10661014Z', $dt->epoch(),
	q{Parse ISO-8601 '10661014Z'} );

    call_m( parse => '1066ad1014Z', $dt->epoch(),
	q{Parse ISO-8601-ish '1066ad1014Z'} );

    $dt = DateTime->new(	# Great fire of Rome
	year	=> 64,
	month	=> 7,
	day	=> 19,
	time_zone	=> 'UTC',
    );

    call_m( parse => '64CE-7-19 Z', $dt->epoch(),
	q{Parse ISO-8601-ish '64CE-7-19 Z'} );

    $dt = DateTime->new(	# Asassination of J. Caesar
	year	=> -43,
	month	=> 3,
	day	=> 15,
	time_zone	=> 'UTC',
    );

    call_m( parse => '44BC/3/15 ut', $dt->epoch(),
	q{Parse ISO-8601-ish '44BC/3/15 ut'} );

    call_m( parse => '44bce 3 15 gmt', $dt->epoch(),
	q{Parse ISO-8601-ish '44bce 3 15 gmt'} );

}

SKIP: {
    my $tests = 6;

    load_or_skip( 'DateTime::Calendar::Christian', $tests );

    note <<'EOD';

We only do the following if DateTime::Calendar::Christian can be loaded.

EOD

    call_m( new =>
	class		=> 'Astro::App::Satpass2::ParseTime::ISO8601',
	back_end	=> 'Christian',
	INSTANTIATE, 'Instantiate' );

    my $dt = DateTime::Calendar::Christian->new(	# Battle of Hastings
	year	=> 1066,



( run in 1.518 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )