Auction expiration field fails to validate when using non-US date/time format
rsm08 - April 20, 2009 - 21:04
| Project: | Ubercart Auction |
| Version: | 6.x-1.x-dev |
| Component: | User interface |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
Hi Garrett
I think there's several problems with the way that the auction expiration time is set:
- When using another language than English, the option to enter a PHP datetime addition directly (like "+7 days" or "+48 hours" isn't usable
- When having non-US datetime settings, it's more or less impossible to enter the correct dateformat for a specific date, and if fx "+7 days" is entered instead (and accepted) when the node is created, the date will still display in the local format, so when the node is saved after editing, the form won't validate, even though no change has been made by the user
- From a usability perspective, non-technical users shouldn't be allowed so much freedom (= so many ways to screw up) as is given by free text input. Instead there should be more control. I'm thinking of a good old fashioned date selector and maybe a time dropdown field.
I'd like to hear your thoughts on this!

#1
The expiration time field is passed to PHP's strtotime() function, so it will have the same flaws as that function; namely, an inability to function with non-English words and time formats.
The second bullet point there is particularly disturbing, though. You've convinced me that using a date field or calendar dropdown would probably be better. I'll look into it when I can start doing some serious work on this project again.
#2
OMG OMG OMG!!! I can't believe how easy that was!
In uc_auction_form_alter(), just change this:
'expiry' => array('#type' => 'textfield',
'#title' => t('Expiration date & time'),
'#description' => t('Specify a precise time such as %prec or a time relative to the moment this form is submitted such as <em>+7 days</em>.', array('%prec' => format_date(strtotime('+7 days'), 'custom', 'r'))),
'#default_value' => $expiry,
'#weight' => 10,
),
... to this:
'expiry' => array('#type' => 'date_popup',
'#title' => t('Expiration date & time'),
'#description' => t('Specify the date and time that the auction will end.'),
'#default_value' => $expiry,
'#weight' => 10,
),
... and see the magic happen! ;)
It requires the Date Popup submodule of the Date module, but most people will have that module installed.
#3
I don't know about most people. That's a good solution, and probably the one I'll end up going with, but I'd want to also change the .info file so that the Date and Date Popup modules are required.
#4
If you don't want to require the Date module, you can just make an if statement and check for it in the form_alter function, so if they don't have the module, it can revert to the current interface. Your existing submit handling can deal with both formats already anyway.
#5
Oh, I found out there was one more thing neccesary for the date popup to work when updating an existing node.
Line 131 (or nearby) has to be changed to this, which is the only input format that the date_popup field default value will accept:
$expiry = date('Y-m-d H:i:s', $form['#node']->uc_auction['expiry']);#6
Yes, the most recent dev release should reflect that. I'm going to go ahead and mark this as fixed.
#7
Automatically closed -- issue fixed for 2 weeks with no activity.