? No Code Attached Yet
avatar thanhnv37
thanhnv37
26 Nov 2019

Is your feature request related to a problem? Please describe.

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.

Describe the solution you'd like

Additional context

avatar thanhnv37 thanhnv37 - open - 26 Nov 2019
avatar joomla-cms-bot joomla-cms-bot - change - 26 Nov 2019
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 26 Nov 2019
avatar infograf768
infograf768 - comment - 26 Nov 2019

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.

avatar thanhnv37
thanhnv37 - comment - 26 Nov 2019

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.

avatar infograf768
infograf768 - comment - 26 Nov 2019

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?

avatar dgrammatiko
dgrammatiko - comment - 26 Nov 2019

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?

avatar thanhnv37
thanhnv37 - comment - 26 Nov 2019

@dgrammatiko
I am developer of Geek ElasticSearch component, it uses Javascript to query and parse data directly from Elasticsearch server.

avatar dgrammatiko
dgrammatiko - comment - 26 Nov 2019

@thanhnv37

const entryMonth = date.getMonth()
const passThisMonth = entryMonth() < 10 ? `0${entryMonth}` : `${entryMonth}`
avatar thanhnv37
thanhnv37 - comment - 26 Nov 2019

@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.

  • media/system/js/fields/calendar-locales/date/gregorian/date-helper.js
  • media/system/js/fields/calendar-locales/date/jalali/date-helper.js

Thanks

avatar brianteeman
brianteeman - comment - 15 Dec 2019

@thanhnv37 As a developer the best and fastest way to support this is for you to submit a pull request

avatar Hackwar Hackwar - change - 19 Feb 2023
Labels Added: ? No Code Attached Yet
Removed: ?
avatar Hackwar Hackwar - labeled - 19 Feb 2023

Add a Comment

Login with GitHub to post a comment