Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Critical
-
Resolution: Fixed/Completed
-
Affects Version/s: 1.7, 1.8
-
Fix Version/s: 1.8
-
Component/s: Core CiviCRM
-
Labels:None
Description
Example use case (this is just one instance, I think we have this problem in many other places):
0. Do a clean database setup, make sure that Global options -> Date is set to defaults
1. Go to Activities, enter new Activity adding screen - you'll see Scheduled time being set to now.
2. Go to Administer CiviCRM -> Global options -> Date and change 12 hour date format (%I) to 24 hour date format (%H).
3. Got to Activities adding screen again - you'll see that hour default is not being set or is being set to wrong hour. DISCLAIMER: please do this test BETWEEN midnight and noon PST, this bug doesn't show up in afternoons and evenings. (explained below)
This is a problem with the way we handle default date setting. The code for above example is in CRM/Activities/Form.php, in setDefaultValues() function:
(line 161)
$defaults['scheduled_date_time'] = array( 'Y' => date('Y'),
'M' => date('m'),
'd' => date('d'),
'h' => date('h'),
'i' => $min,
'A' => date('A') );
In the example given above, we're setting 'h' as default for hour field (which is 12-hour format of an hour with leading zeros), but the form is set to use 'H' (which is 24-hour format of an hour with leading zeros). The effect is probably always displaying hours from 0am to 12pm only.
Proposed solution:
- We can create a function in CRM_Utils_Date which - given specific date (or no arguments for now) will return proper defaults array based on date format configuration. This change will need to be incorporated in all the places where we set default date in form.