-
-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use time strings formatted for the locale for homework set dates.
Instead of formatting the unix timestamp for display in the inputs for dates in the instructor tools, just use the unix timestamp in those inputs. The flatpickr javascript now hides those inputs and adds an input that the user actually sees. That input contains a localized time string that is formatted for the locale (language) of the course via native javascript's Intl.DateTimeFormat. The flatpickr javascript takes care of updating the value of the hidden input with a unix timestamp as the user changes the visible input. To make this work well the dates that are only used for display are formatted with a different approach by Perl. The DateTime format_cldr is used for this instead of strftime. This allows for the use of the DateTime::Locale methods which provides uniform formatting for different languages. A special case is added to the lib/WeBWorK/Utils.pm formatDateTime function to handle this. To be precise, javascript uses Intl.DateTimeFormat with the options `{ dateStyle: 'short', timeStyle: 'short' }`, and perl uses the formatting string returned by `$dt->locale->datetime_format_short`. This also makes things work cleaner in the way that the server handles dates because you don't need to worry about parsing a date string back to a unix timestamp. For most languages the perl DateTime::Locale formatting and javascript Intl.DateTimeFormat formatting are the same. Unfortunately, for a few languages Perl's DateTime::Locale formatting is not correct. This can be seen when editing a problem set values for a user. The user values are formatted by javascript, and the class values by perl. The languages that seem to have problems here are any of the Asian languages. In Korean javascript gives `22. 3. 16. 오전 12:00` and perl gives `23. 3. 16. AM 12:00`. Clearly perl is not properly translating the AM/PM part. For zh_CN javascript gives `2022/3/16 00:00` and perl gives `2022/3/16 上午12:00`. Javscript gives a 24 hour time, and perl uses a 12 hour time. For zh_hk javascript gives `16/3/2022 上午12:00` and perl gives `2022/3/16 上午12:00`. So perl does not seem to use the correct ordering of the year, month, and day for that locale. Of course this means that the old strftime format `%m/%d/%Y at %I:%M%P` is not used for set dates anymore. For English the CLDR format returned by `datetime_format_short` that is now used is `M/d/yy, h:mm a`. This means instead of `03/16/2022 at 12:00am` you get `3/16/22, 12:00 AM`. I would prefer `03/16/2022, 12:00 AM`, but that is what our locale gives consistently for javascript and perl. So it is probably best to go with the standard. Note that the old format is still used for set export and import files. In fact that is the only place that the parseDateTime method is still used. It is used there to ensure that the correct timezone is set for the saved dates. Note that the `useDateTimePicker` option has been removed. That could be re-implemented if desired, but it would be a bit tedious to do so. The problem is that the date/time picker does not format and parse dates, but if that option is disabled then you would need to. I don't really see the need for that option anymore though. There is a minor change in the lib/WeBWorK/Utils/LanguageAndDirection.pm file. That was using the po filenames directly for the html `lang` attribute. Those filenames use underscores which are not valid for the `lang` attribute. So the underscores are translated to dashes.
- Loading branch information
Showing
16 changed files
with
481 additions
and
394 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,6 +82,15 @@ | |
"node_modules/codemirror/lib/codemirror.js": "https://cdn.jsdelivr.net/npm/[email protected]/lib/codemirror.min.js", | ||
"node_modules/flatpickr/dist/flatpickr.min.css": "https://cdn.jsdelivr.net/npm/[email protected]/dist/flatpickr.min.css", | ||
"node_modules/flatpickr/dist/flatpickr.min.js": "https://cdn.jsdelivr.net/npm/[email protected]/dist/flatpickr.min.js", | ||
"node_modules/flatpickr/dist/l10n/cs.js": "https://cdn.jsdelivr.net/npm/[email protected]/dist/l10n/cs.min.js", | ||
"node_modules/flatpickr/dist/l10n/es.js": "https://cdn.jsdelivr.net/npm/[email protected]/dist/l10n/es.min.js", | ||
"node_modules/flatpickr/dist/l10n/fr.js": "https://cdn.jsdelivr.net/npm/[email protected]/dist/l10n/fr.min.js", | ||
"node_modules/flatpickr/dist/l10n/he.js": "https://cdn.jsdelivr.net/npm/[email protected]/dist/l10n/he.min.js", | ||
"node_modules/flatpickr/dist/l10n/hu.js": "https://cdn.jsdelivr.net/npm/[email protected]/dist/l10n/hu.min.js", | ||
"node_modules/flatpickr/dist/l10n/ko.js": "https://cdn.jsdelivr.net/npm/[email protected]/dist/l10n/ko.min.js", | ||
"node_modules/flatpickr/dist/l10n/ru.js": "https://cdn.jsdelivr.net/npm/[email protected]/dist/l10n/ru.min.js", | ||
"node_modules/flatpickr/dist/l10n/tr.js": "https://cdn.jsdelivr.net/npm/[email protected]/dist/l10n/tr.min.js", | ||
"node_modules/flatpickr/dist/l10n/zh.js": "https://cdn.jsdelivr.net/npm/[email protected]/dist/l10n/zh.min.js", | ||
"node_modules/flatpickr/dist/plugins/confirmDate/confirmDate.css": "https://cdn.jsdelivr.net/npm/[email protected]/dist/plugins/confirmDate/confirmDate.min.css", | ||
"node_modules/flatpickr/dist/plugins/confirmDate/confirmDate.js": "https://cdn.jsdelivr.net/npm/[email protected]/dist/plugins/confirmDate/confirmDate.min.js", | ||
"node_modules/iframe-resizer/js/iframeResizer.contentWindow.min.js": "https://cdn.jsdelivr.net/npm/[email protected]/js/iframeResizer.contentWindow.min.js", | ||
|
Oops, something went wrong.