$val->{"pickup_lib"} = $self->cgi->param("pickup_lib");
for my $field (qw/expire_time thaw_date/) {
- # XXX TODO make this support other date formats, not just
- # MM/DD/YYYY.
- next unless $self->cgi->param($field) =~
- m:^(\d{2})/(\d{2})/(\d{4})$:;
- $val->{$field} = "$3-$1-$2";
+ my $param_value = $self->cgi->param($field);
+ # Check for US date format grandfathered in for XUL.
+ if ($param_value =~ m:^(\d{2})/(\d{2})/(\d{4})$:) {
+ $val->{$field} = "$3-$1-$2";
+ } elsif ($param_value =~ m:^\d{4}-\d{2}-\d{2}$:) {
+ # It looks like an ISO date from HTML5 date input.
+ $val->{$field} = $param_value;
+ }
+ # Otherwise, we drop it on the floor.
}
$val->{holdable_formats} = # no-op for non-MR holds
}
if ($cgi->param('hold_suspend')) {
$ctx->{frozen} = 1;
- # TODO: Make this support other date formats, not just mm/dd/yyyy.
- # We should use a date input type on the forms once it is supported by Firefox.
- # I didn't do that now because it is not available in a general release.
- if ($cgi->param('thaw_date') =~ m:^(\d{2})/(\d{2})/(\d{4})$:){
+ # We now use a HTML5 date input, but we're leaving this check in place
+ # just in case.
+ if ($cgi->param('thaw_date') =~ m:^\d{4}-\d{2}-\d{2}$:) {
+ $ctx->{thaw_date} = $cgi->param('thaw_date');
+ } elsif ($cgi->param('thaw_date') =~ m:^(\d{2})/(\d{2})/(\d{4})$:){
eval {
my $dt = DateTime::Format::ISO8601->parse_datetime("$3-$1-$2");
$ctx->{thaw_date} = $dt->ymd;
if ($@) {
$logger->warn("ignoring invalid thaw_date when placing hold request");
}
+ } else {
+ $logger->warn("ignoring invalid thaw_date when placing hold request");
}
}
hold.human_status = PROCESS get_hold_status hold=hold;
# Do this up front to avoid verbosity later
- expire_time = ahr.expire_time ? date.format(ctx.parse_datetime(ahr.expire_time), DATE_FORMAT) : '';
- thaw_date = ahr.thaw_date ? date.format(ctx.parse_datetime(ahr.thaw_date), DATE_FORMAT) : '';
+ # The HTML5 date element needs an ISO string for the value.
+ expire_time = ahr.expire_time ? date.format(ctx.parse_datetime(ahr.expire_time), '%Y-%m-%d') : '';
+ # The HTML5 date element needs an ISO string for the value.
+ thaw_date = ahr.thaw_date ? date.format(ctx.parse_datetime(ahr.thaw_date), '%Y-%m-%d') : '';
%]
<h3 class="sr-only">[% l('Edit Hold') %]</h3>
<div class="pad-bottom-five">
[% l('Cancel unless filled by') %]
</th>
<td>
- <input type="text" name="expire_time"
- value="[% expire_time | html %]" />
- </td>
- <td class="fmt-note">
- <em>[% l('Enter date in MM/DD/YYYY format') %]</em>
- <!-- XXX TODO pick out a minimal, simple, reliable
- calendar widget that's not part of some giant,
- bloated framework and doesn't do anything at onload.
- -->
+ <input type="date" name="expire_time"
+ value="[% expire_time | html %]"
+ min="[% get_tomorrow_date | html; %]" />
</td>
</tr>
<tr>
[% l('If suspended, activate on') %]
</th>
<td>
- <input type="text" name="thaw_date"
- value="[% thaw_date | html %]" />
- </td>
- <td class="fmt-note">
- <em>[% l('Enter date in MM/DD/YYYY format') %]</em>
+ <input type="date" name="thaw_date"
+ value="[% thaw_date | html %]"
+ min="[% get_tomorrow_date | html; %]" />
</td>
</tr>
[% END %]
-
+
<tr><td colspan='4'>
[% IF hold.metarecord_filters.formats.size OR
(hold.metarecord_filters.langs.size.defined && hold.metarecord_filters.langs.size > 1);
|| CGI.param(loc_name) || CGI.param('loc') || ctx.search_ou;
END;
+ # Get an ISO date string for tomorrow's date for use in hold
+ # suspension date elements.
+ MACRO get_tomorrow_date BLOCK;
+ manip = date.manip;
+ manip.UnixDate('Noon Tomorrow', '%Y-%m-%d');
+ END;
-%]
</blockquote>
<blockquote id="toggled-block-suspend">
<label for="thaw_date">[% l('Activate on') %]</label>
- <input type="text" id="thaw_date" name="thaw_date" />
+ <input type="date" id="thaw_date" name="thaw_date"
+ min="[% get_tomorrow_date | html; %]" />
+ [% IF ctx.proto == 'oils' %]
<em>[% l('Enter date in MM/DD/YYYY format') %]</em>
+ [% END %]
</blockquote>
</p>
<input id="place_hold_submit" type="submit" name="submit"