https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26053
--- Comment #29 from Emily Lamancusa <[email protected]> --- > Also UT helped me to find an issue with expiration = today, one must use day > truncation like in Koha::Patron : > dt_from_string->truncate( to => 'day' ); Hmmm, it looks like Koha::Patron is inconsistent with itself in that. $patron->is_expired uses: return 1 if dt_from_string( $self->dateexpiry ) < dt_from_string->truncate( to => 'day' ); $patron->password_expired uses: return 1 if dt_from_string( $self->password_expiration_date ) <= dt_from_string->truncate( to => 'day' ); $patron->is_debarred uses: return $self->debarred if $self->debarred =~ '^9999' or dt_from_string( $self->debarred ) > dt_from_string; We should probably standardize those on another bug... I don't think we should be truncating just one, though. Then if the expiration date == today, we're comparing, for instance, '2023-09-29 00:00:00' to '2023-09-29', which should be equal, but won't evaluate to equal. We should truncate either both or neither. In any case, in this particular situation, the behavior should match the behavior of $patron->is_debarred, since we're looking at restrictions. If the restriction's expiration date is today, it would compare: '2023-09-29 00:00:00' > '2023-09-29 09:31:23' (or whatever the current time is), which would return false (the patron is not debarred), which means the restriction IS expired. I don't see a coding guideline about whether to truncate or not, so I think that's up to you. To make the behavior consistent with is_debarred, it would need to be either: dt_from_string( $self->expiration ) < dt_from_string or if dt_from_string( $self->expiration )->truncate( to => 'day' ) <= dt_from_string->truncate( to => 'day' ) -- You are receiving this mail because: You are watching all bug changes. _______________________________________________ Koha-bugs mailing list [email protected] https://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/
