Datepicker doesnt work with different date formats

Bug #1831689 reported by Liam on 2019-06-05
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Status tracked in 19.10
19.04
High
Unassigned
19.10
High
Unassigned

Bug Description

When a different date format (other than the Mahara default YYYY/MM/DD HH:mm), the datepicker doesnt work.

Steps to reproduce:
1. Update lang/en.utf8/langconfig.php with the following:

$string['pieform_calendar_dateformat'] = '%%d/%%m/%%Y';
$string['pieform_calendar_timeformat'] = '%%l:%%M %%p';

2. Clear site cache

3. In the Shared by Me, set 'Allow comments' = Yes

4. Enter a page to share with a group with an end date selected from outside of the current month.

5. Save and re-enter the page.

Expected result: Clicking on the 'to' field opens the datepicker
Actual result: the datepicker doesnt open and error messages are displayed in the console.

Steps I've tried to fix:
-Hard coding the new date format (DD/MM/YYYY h:mm A) into theme/raw/templates/form/viewacl.tpl:164
-Adding new code to the library as per https://github.com/tempusdominus/bootstrap-4/issues/193#issuecomment-465649868
-Removing the local from theme/raw/templates/form/viewacl.tpl:165

description: updated
Changed in mahara:
importance: Undecided → High
Robert Lyon (robertl-9) wrote :

Strange - I try replicating the steps above on master in Firefox / Chrome and I have no problem saving / editing the date in the new format if the date is non-ambiguous

Eg if the date I enter / edit is 27/09/2019 07:36 AM then all works fine

but if I enter and save 04/09/2019 07:36 AM then try to edit it fails

I believe this is because 04/09/2019 can mean both 04 Sept 2019 and April 09 2019 so things break as we are being unclear

Robert Lyon (robertl-9) wrote :

I've added a patch that seems to sort our problem - there is still a warning when first initializing the datepicker for the first time with a set date - as it calls getMoment() before it checks format and so complains about the date being of bad format - but once it initialises with this._initFormatting() fully the date format is set correctly

Changed in mahara:
status: Confirmed → In Progress
Mahara Bot (dev-mahara) wrote :

Patch for "master" branch: https://reviews.mahara.org/10076

Reviewed: https://reviews.mahara.org/10074
Committed: https://git.mahara.org/mahara/mahara/commit/afd9e7a726aef567921b9b275d44ac549947543e
Submitter: Robert Lyon (<email address hidden>)
Branch: master

commit afd9e7a726aef567921b9b275d44ac549947543e
Author: Robert Lyon <email address hidden>
Date: Wed Jun 12 10:26:23 2019 +1200

Bug 1831689: Adjusting how we update dates on the the view access page

There was a problem where we set up fields with empty date and then
try to add a date to it

Instead we should set up the datepicker with the date so that works
out what type of date it is first so then can handle it correctly

Note: if trying to use format DD/MM/YYYY it will complain that it is a
non-compatible date

behatnotneeded

Change-Id: I401e0812dc2c4189b715033fcf7b745c52425b05
Signed-off-by: Robert Lyon <email address hidden>

Reviewed: https://reviews.mahara.org/10108
Committed: https://git.mahara.org/mahara/mahara/commit/d3d2359ff4c12c1f2699da932c5e77c6edfafd21
Submitter: Robert Lyon (<email address hidden>)
Branch: 19.04_STABLE

commit d3d2359ff4c12c1f2699da932c5e77c6edfafd21
Author: Robert Lyon <email address hidden>
Date: Wed Jun 12 10:26:23 2019 +1200

Bug 1831689: Adjusting how we update dates on the the view access page

There was a problem where we set up fields with empty date and then
try to add a date to it

Instead we should set up the datepicker with the date so that works
out what type of date it is first so then can handle it correctly

Note: if trying to use format DD/MM/YYYY it will complain that it is a
non-compatible date

behatnotneeded

Change-Id: I401e0812dc2c4189b715033fcf7b745c52425b05
Signed-off-by: Robert Lyon <email address hidden>
(cherry picked from commit afd9e7a726aef567921b9b275d44ac549947543e)

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers