Skip to content

Commit

Permalink
Time::D: fix bug with setting values in negative diffs
Browse files Browse the repository at this point in the history
  • Loading branch information
pink-mist committed Nov 1, 2016
1 parent 84b53d9 commit 09e4906
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/Time/D.pm
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ method _computed_setter ($d: $key, $new) {

my $ct = Time::C->gmtime($d->comp);
return $val, sub {
$ct->$key -= $val - $_[0];
if ($diff{sign} eq '-') {
$ct->$key -= $_[0] - $val;
} else {
$ct->$key -= $val - $_[0];
}
$d->comp = $ct->epoch;

return $d if defined $new;
Expand Down

0 comments on commit 09e4906

Please sign in to comment.