This patch fixes a bug where editing the due date of an hourly
loan would result in the time portion always getting set to 00:00.
To test
-------
[1] Set up some daily and hourly loans in your database.
[2] Apply the patch.
[3] From the items out page, edit the due date for one or
more hourly loans. Verify that the resulting due date
is set correctly.
[4] From the items out page, edit the due date for some
daily loans and verify correctness. In particular,
verify that the resulting due date is /not/ the
following day if testing in time zones in the Americas.
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
if (!(interval_to_seconds($circ->duration) % 86400)) { # duration is divisible by days
my $original_date = DateTime::Format::ISO8601->new->parse_datetime(clean_ISO8601($circ->due_date));
my $new_date = DateTime::Format::ISO8601->new->parse_datetime($date);
+
+ # since the new date may be coming in as UTC, convert it
+ # to the same time zone as the original due date so that
+ # ->ymd is more likely to yield the expected results
+ $new_date->set_time_zone($original_date->time_zone());
$date = clean_ISO8601( $new_date->ymd . 'T' . $original_date->strftime('%T%z') );
}
// Fire off the due-date updater for each circ.
// When all is done, close the dialog
$scope.ok = function(args) {
- // toISOString gives us Zulu time, so
- // adjust for that before truncating to date
- var adjust_date = new Date( $scope.args.due_date );
- adjust_date.setMinutes(
- $scope.args.due_date.getMinutes() - adjust_date.getTimezoneOffset()
- );
- var due = adjust_date.toISOString().replace(/T.*/,'');
+ var due = $scope.args.due_date.toISOString();
console.debug("applying due date of " + due);
var promises = [];