Skip to content

Truncate ignores DST flag. Bug or intended behavior? #135

@bbkr

Description

@bbkr
use DateTime;
my $dt = DateTime->new( "year" => 2022, "month" => 10, "day" => 30, "hour" => 1, "time_zone" => "Europe/Dublin" );
say $dt->is_dst;
$dt->add( "hours" => 1 );
say $dt->is_dst;
$dt->truncate( "to" => "hour" );
say $dt->is_dst;

Output:

0
1
0

So truncate rewinded time back to hour before DST gap.

  • From relative time perspective it looks incorrect - there is nothing to truncate in 2022-10-30T01:00:00.
  • From absolute time perspective it looks correct - there are extra 3600 seconds that could be chopped to reach 2022-10-30T01:00:00.

If this is correct behavior i think it should be mentioned in truncate and set methods.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions