Adding and subtracting small durations doesn't appear to
affect the epoch. I tried adding a line to recalculate it,
but that just seemed to screw things up elsewhere.

Tests:

# Adding/subtracting should affect epoch
{
    my $expected = '1049160602';
    my $epochtest = DateTime->from_epoch( epoch => $expected  );

    is( $epochtest->epoch, $expected,
        "epoch method returns correct value ($expected)");
    is( $epochtest->hour, 1, "hour" );
    is( $epochtest->min, 30, "minute" );

    diag scalar localtime($expected);
    diag scalar localtime($epochtest->epoch);
    $epochtest->add( hours => 2 );
    $expected += 2*60*60;
    diag scalar localtime($expected);
    diag scalar localtime($epochtest->epoch);

    is( $epochtest->hour, 3, "adjusted hour" );
    is( $epochtest->epoch, $expected,
        "epoch method returns correct adjusted value ($expected)");

}


-- 
Iain.

Reply via email to