https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23079
--- Comment #11 from M. Tompsett <[email protected]> --- (In reply to Jonathan Druart from comment #10) > (In reply to M. Tompsett from comment #9) > > Comment on attachment 90940 [details] [review] [review] > > Bug 23079: Handle invalid timezones when adding/subtracting durations > > > > Review of attachment 90940 [details] [review] [review]: > > ----------------------------------------------------------------- > > > > ::: Koha/Patron.pm > > @@ +622,4 @@ > > > return 0 unless $delay; > > > return 0 unless $self->dateexpiry; > > > return 0 if $self->dateexpiry =~ '^9999'; > > > + return 1 if dt_from_string( $self->dateexpiry, undef, 'floating' > > > )->subtract( days => $delay ) < dt_from_string(undef, undef, > > > 'floating')->truncate( to => 'day' ); > > > > I'd prefer GMT. > > Why? https://metacpan.org/pod/DateTime#How-DateTime-Math-Works Nice long read of recommendations. Floating is fine if we don't care about leap days/seconds, but if we are subtracting days, then perhaps we do care? "If you can always use the floating or UTC time zones, you can skip ahead to "Leap Seconds and Date Math" " So, this uses floating, I'd prefer UTC. Floating is good if we don't care about partial days, but... "$dt->subtract( $duration_object ) A synonym of $dt->subtract_duration( $duration_object )." -- implying we care about partial days. "If you only care about the date (calendar) portion of a datetime, you should use either delta_md() or delta_days(), not subtract_datetime(). This will give predictable, unsurprising results, free from DST-related complications." In short, floating is perfectly okay if we don't care about partial days, do we? > > > ::: acqui/duplicate_orders.pl > > @@ +74,4 @@ > > > > > > unless ( $input->param('from') ) { > > > # Fill the form with year-1 > > > + $from_placed_on->set_time_zone('floating')->subtract( years => 1 ); > > > > Why not: > > $from_placed_on->set_year($from_placed_on->year() - 1); > > -- no timezone needed. > > Hum? I do not understand how it will fix the problem. When timezones are involved weird and wonderful maths are necessary. Since we are just looking for last year, and the time in the current date is valid (otherwise it would have blown up sooner) merely changing just the year back one year avoids anything that might pass-through bizarre timezone stuff. Though, perhaps we care about that? If we care about partial days, then floating is wrong. If we don't, then floating is okay. -- You are receiving this mail because: You are watching all bug changes. _______________________________________________ Koha-bugs mailing list [email protected] http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
