"Edit access" screen has trouble with jscalendar dates if you change calendar_dateFormat and/or strtimedatetimeshort

Bug #1455137 reported by David Truong
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
Medium
Unassigned
1.10
Won't Fix
Medium
Unassigned
15.04
Fix Released
Medium
Unassigned
15.10
Fix Released
Medium
Unassigned

Bug Description

This is a follow up on Bug #1376997 Date picker not working for certain languages
The date picker works with the dd.mm.yy format when editing access ("shared by me" page).

However if you are to change in langconfig.php the parameters to a french format:
$string['calendar_dateFormat']= 'dd/mm/yy';
$string['strftimedatetimeshort'] = '%%d/%%m/%%Y %%H:%%M';

You can use the date picker and define a new access. However, you cannot edit a preexisting access besause it doesnt show up when you go to edit it. You are forced to redefine all your access if you want to modify anything.

Theres also a problem when you try to define "Access start date/time" and "Access end date/time" in the Advanced option. It will take the dd/mm/yy format of the datepicker. However, you cannot choose a day higher then 12. You can on the other hand enter a mm/dd/yy format into the textbox manually to define the access.

If the code itself is too complicated to fix, there should at least be a converter to show the chosen date format to the users.

David Truong (dttam2)
description: updated
Aaron Wells (u-aaronw)
Changed in mahara:
status: New → Confirmed
importance: Undecided → Medium
summary: - Edit access not working in french
+ "Edit access" screen has trouble with jscalendar dates if you change
+ calendar_dateFormat and/or strtimedatetimeshort
Revision history for this message
Aaron Wells (u-aaronw) wrote :

Hi David,

I've confirmed this problem. For now, the workaround is to change calendar_dateFormat and strftimedatetimeshort back to the originals from the English langpack. (And update the lang strings for the help text, to match.) I've looked through the code and verified that calendar_dateFormat and strftimedatetimeshort are nearly only used for the JS calendar widget (strftimedatetimeshort also has a couple of other minor uses, usually in outputting data to admins).

Going forward, here's what I would suggest for the fix:

1. For the calendar, instead of using "strftimedatetimeshort", we use a new lang string called "calendar_phpdatetimeformat".

2. We rename "calendar_dateformat" to "calendar_jsdateformat", and "calendar_timeformat" to "calendar_jstimeformat".

3. Items #1 and #2 together should help make it clearer to devs that these strings must match each other.

4. If possible we add some code to the Pieform calendar and acl elements, so that they themselves do the date format validation, and so that they render the human-readable date into a hard-coded format by the time it gets sent to the form's "_submit" function. That way, we won't have to rely on the devs remembering to use the correct lang strings to parse and validate the calendar's dates on every form where it is used. (It is evident we devs have not been remembering to do that.)

5. If #4 is not possible, at least add some documentation to the Pieform calendar and acl elements. And go through all the forms that use them and fix their validation and submission code.

Unfortunately, this is a non-trivial fix, so I'm probably not going to get to it immediately. In the meantime, I'd suggest using that workaround, of changing calendar_dateFormat and strftimedatetimeshort back to the original values. This shouldn't be a huge inconvenience to your users, because the JS calendar widget means they shouldn't actually need to type in a date anyway.

Cheers,
Aaron

Revision history for this message
Luca Bösch (boesl2) wrote :

I confurm this bug (obviously) also affecting a german language Mahara.

Revision history for this message
Kristina Hoeppner (kris-hoeppner) wrote :

In https://mahara.org/interaction/forum/topic.php?id=7342&offset=0&limit=10#post29498 Conrad reported the following for German:

When he adds a secret URL, the workaround fixes the date, but not the time. The time is still shown only in 12h-modus but not 24-hour modus. When he enters 25.08.2015 03:45 he gets an error message because it is interpreted as 3:45 a.m. However when he changes the time manually to 15:45, it works.

Revision history for this message
Kristina Hoeppner (kris-hoeppner) wrote :

Conrad changed the following in his language pack and that resolved the problem. If there is a more permanent fix that would be great.

In
/langpacks/de.utf8/lang/de.utf8/langconfig.php

changed line
$string['calendar_timeFormat'] = 'hh:mm';

to
$string['calendar_timeFormat'] = 'HH:mm';

Now the time is shown in 24-hour format.

Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

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

Revision history for this message
Aaron Wells (u-aaronw) wrote :

The fix for this is rather complicated, so we won't backport it to 1.10.

Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/5201
Committed: https://git.nzoss.org.nz/mahara/mahara/commit/287b679440f7e2309c17869e04de3940e5affa7d
Submitter: Aaron Wells (<email address hidden>)
Branch: master

commit 287b679440f7e2309c17869e04de3940e5affa7d
Author: Aaron Wells <email address hidden>
Date: Mon Aug 24 18:24:27 2015 +1200

Straightening out the language string situation in the JS calendar (bug 1455137)

The main thing this fixes, is that it causes the JS calendar to use ONLY the
new lang strings pieform_calendar_dateformat & pieform_calendar_timeformat,
for its formatting. These strings are in strftime() format, and are converted
into the JQuery Datepicker/Timepicker format by PHP (if we change to a different
calendar plugin in the future, we can change the PHP conversion function).

This fixes the bug where translators could break the calendar by changing the
JS format strings so they no longer matched the PHP format strings.

As a side effect of this change, I've also made it so that the help strings
are derived from the format string, and are translatable.

behatnotneeded: Date field is already tested by resume_page.feature

Change-Id: I152962cc27f36f93b51ee0327ed942fb089f7f5b

Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "15.10_STABLE" branch: https://reviews.mahara.org/5613

Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/5613
Committed: https://git.nzoss.org.nz/mahara/mahara/commit/e797169819c031a373e39935bb214ab39039fa0a
Submitter: Aaron Wells (<email address hidden>)
Branch: 15.10_STABLE

commit e797169819c031a373e39935bb214ab39039fa0a
Author: Aaron Wells <email address hidden>
Date: Mon Aug 24 18:24:27 2015 +1200

Straightening out the language string situation in the JS calendar (bug 1455137)

The main thing this fixes, is that it causes the JS calendar to use ONLY the
new lang strings pieform_calendar_dateformat & pieform_calendar_timeformat,
for its formatting. These strings are in strftime() format, and are converted
into the JQuery Datepicker/Timepicker format by PHP (if we change to a different
calendar plugin in the future, we can change the PHP conversion function).

This fixes the bug where translators could break the calendar by changing the
JS format strings so they no longer matched the PHP format strings.

As a side effect of this change, I've also made it so that the help strings
are derived from the format string, and are translatable.

behatnotneeded: Date field is already tested by resume_page.feature

Change-Id: I152962cc27f36f93b51ee0327ed942fb089f7f5b
(cherry picked from commit 287b679440f7e2309c17869e04de3940e5affa7d)

Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "15.04_STABLE" branch: https://reviews.mahara.org/5614

Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/5614
Committed: https://git.nzoss.org.nz/mahara/mahara/commit/43a6c846dd5c0d40106cba2a5d5353aa6a60038a
Submitter: Robert Lyon (<email address hidden>)
Branch: 15.04_STABLE

commit 43a6c846dd5c0d40106cba2a5d5353aa6a60038a
Author: Aaron Wells <email address hidden>
Date: Mon Aug 24 18:24:27 2015 +1200

Straightening out the language string situation in the JS calendar (bug 1455137)

The main thing this fixes, is that it causes the JS calendar to use ONLY the
new lang strings pieform_calendar_dateformat & pieform_calendar_timeformat,
for its formatting. These strings are in strftime() format, and are converted
into the JQuery Datepicker/Timepicker format by PHP (if we change to a different
calendar plugin in the future, we can change the PHP conversion function).

This fixes the bug where translators could break the calendar by changing the
JS format strings so they no longer matched the PHP format strings.

As a side effect of this change, I've also made it so that the help strings
are derived from the format string, and are translatable.

behatnotneeded

Change-Id: I152962cc27f36f93b51ee0327ed942fb089f7f5b

Robert Lyon (robertl-9)
Changed in mahara:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.