https://docs.joomla.org/Calendar_form_field_type
Could you please add a new date formatting option for representation of the month without leading zero.
Labels |
Added:
?
|
Hello @infograf768
Thank you for your answers.
But I don't use PHP date format function, I use the Javascript date helper library defined in file below
media/system/js/fields/calendar-locales/date/gregorian/date-helper.js
I checked this library and it currently does not support formatting option for displaying month without leading zero.
The display format, when translateformat
is true, is set in
/libraries/joomla/form/fields/calendar.php
and it uses the percent format type but indeed this is not where the 0 is added.
The library is adding a 0
when the month is less than 10 line 355
s["%m"] = (m < 9) ? ("0" + (1+m)) : (1+m); // month, range 01 to 12
Which means we have no choice.
we could maybe add there (but I am not sure at all as %n
is not an acceptable % date format but a newline)
s["%n"] = 1+m; // month, range 1 to 12
which would let use %n
as the variable in the lang strings
But, unhappily, %n
is already used
s["%n"] = "\n"; // a newline character
@dgrammatiko anything we can do?
I checked this library and it currently does not support formatting option for displaying month without leading zero.
Is that when you're inserting a value in the input or parsing the default value thrown by PHP?
@dgrammatiko
I am developer of Geek ElasticSearch component, it uses Javascript to query and parse data directly from Elasticsearch server.
const entryMonth = date.getMonth()
const passThisMonth = entryMonth() < 10 ? `0${entryMonth}` : `${entryMonth}`
@dgrammatiko
Please read a comment of @infograf768
The date helper script does not support formatting option to display week without leading zero, and I hope that you can support this feature on future releases of Joomla.
Thanks
@thanhnv37 As a developer the best and fastest way to support this is for you to submit a pull request
Labels |
Added:
?
No Code Attached Yet
Removed: ? |
The calendar uses the % format in the strings
For French:
DATE_FORMAT_CALENDAR_DATE="%d-%m-%Y"
DATE_FORMAT_CALENDAR_DATETIME="%d-%m-%Y %H:%M:%S"
There is no way to display months without leading zero in this format.
See https://www.php.net/manual/en/function.strftime.php for allowed formats.