Ronald Hill said:
>
> This will not preserve the class information,
> I tried Flavio's suggestion of
> 
> my $tmp_dt1 = $dt->
>          clone->
>          set_time_zone( 'UTC' )->
>          truncate( to => 'day' );
> 
> instead of creating a new object however, 
> I was always getting the incorrect
> date returned.

It may be that setting UTC is changing the
day, because you already have a time zone.
Would you try this instead?

 my $tmp_dt1 = $dt->
          clone->
          set_time_zone( 'floating' )->
          set_time_zone( 'UTC' )->
          truncate( to => 'day' );

It means: "forget about your time zone, and
give me the start of this day number in UTC."

This is untested.

- Flavio S. Glock


Reply via email to