User tests: Successful: Unsuccessful:
Pull Request for Issue #35204 .
Correcting CalendarField::filter to use DATE_FORMAT_FILTER_DATETIME
for translated date.
Was broken somewhere after #12414
Technical note: there should be 2 string translated:
DATE_FORMAT_CALENDAR_DATETIME
- used for display (uses strftime format)
DATE_FORMAT_FILTER_DATETIME
- used for server side filtering (uses datetime format),
Please follow #35204
none
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
Labels |
Added:
?
|
Labels |
Added:
?
Removed: ? |
I tried, it works there.
The date value is sent in "gregorian" for every language.
@Fedik We would get error with Debug Language set to Yes. Basically, in your new code, we will have to process Debug same as how we do in getInput method https://github.com/joomla/joomla-cms/blob/4.0-dev/libraries/src/Form/Field/CalendarField.php#L212-L229
If you don't mind, I want to clean up the code abit more to avoid repeating code (for calculating format in getInput and filter method):
Here is the result https://github.com/joomla/joomla-cms/compare/4.0-dev...joomdonation:calendar_filter?expand=1 (to me, it is cleaner, but maybe it is just me :D
If you like that change, I made PR Fedik#9 to your branch.
If not, please handle the Debug language as I mentioned and I will test it.
Labels |
Added:
?
?
Removed: ? |
well, I do not see language debug manipulation in J3,
joomla-cms/libraries/src/Form/Form.php
Line 1316 in f521d3a
But if something I will tell that it is you
Labels |
Added:
?
?
Removed: ? ? |
I have tested this item
All good now. Thanks !
@PhilETaylor Could you please test it again?
Im going to mark this as successful as it addresses the reported issue
However in testing I was able to break it - with insane values for the format in DATE_FORMAT_CALENDAR_DATETIME
DATE_FORMAT_CALENDAR_DATETIME="%m 2- %d %Y %H:%M:%S"
If the date was today (08-20-2021 04:47:41
) then the above format outputs 08 2- 03 2-2020 11:41:04
which is incorrect.
I have tested this item
Another insane check - on the frontend if I use
DATE_FORMAT_CALENDAR_DATETIME="%m-%d MINE %Y %H:%M:%S"
Then you cannot save - but again I think Im pushing the edges of what we should be supporting here.
Yes. The language file need to provider correct value for these languages item.
Actually, the error happens if users enter random string into the input instead of select a date/time from the picker, but that could be addressed in separate PR
Status | Pending | ⇒ | Ready to Commit |
RTC
Actually, the error happens if users enter random string into the input instead of select a date/time from the picker
I tried that and it handled it well, by removing my rubbish and replacing it with a "now" date/time string.
I tried that and it handled it well, by removing my rubbish and replacing it with a "now" date/time string.
Ah, Yes. A happy strange that no error throws for that case. I thought there would be exception, happy to see that it does not happen. So all good :)
However in testing I was able to break it - with insane values for the format in DATE_FORMAT_CALENDAR_DATETIME
The date constants DATE_FORMAT_CALENDAR_DATETIME
and DATE_FORMAT_FILTER_DATETIME
must be in sync.
DATE_FORMAT_CALENDAR_DATETIME="%m 2- %d %Y %H:%M:%S"
DATE_FORMAT_FILTER_DATETIME="m 2- d Y H:i:s"
and
DATE_FORMAT_CALENDAR_DATETIME="%m-%d MINE %Y %H:%M:%S"
DATE_FORMAT_FILTER_DATETIME="m-d \M\I\N\E Y H:i:s"
This probably a legacy from transition from mootools calendar to current calendar.
It is asking for refactoring, but well, not much easy task.
No worries - like I said, I know I was pushing the extremes and this PR fixes the reported issue.
This probably a legacy from transition from mootools calendar to current calendar.
Yep, I know for a fact. In J3 there was no way to change that at the time
If the new calendar also can use the PHP Date format, then a refactoring would be welcome. You could then use the filter format string and we keep the other for B/C until J5.0.
@dgrammatiko it about using 2 diferent format at same time, currently:
strftime
for calendar js https://www.php.net/manual/en/function.strftime.php for DATE_FORMAT_CALENDAR_DATETIME
datetime
for calendar php https://www.php.net/manual/en/datetime.format.php for DATE_FORMAT_FILTER_DATETIME
If both will use datetime
format, then it could be much simpler.
Or even something from php-intl for correct translations for a dates.
In theory
I just had the same issue with the chinese simplified language pack, and this PR fixed that too.
Status | Ready to Commit | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2021-08-22 22:25:46 |
Closed_By | ⇒ | wilsonge | |
Labels |
Added:
?
?
?
Removed: ? ? |
Thanks!
Has this been tested with Jalali calendar (Persian fa-IR, only available for now as 3.x pack)?