?
avatar GCLW
GCLW
11 Sep 2017

screen shot 2017-09-11 at 21 36 08

Steps to reproduce the issue

Calendar field with time timeformat="12" format="%Y-%m-%d %H:%M:%S"

Expected result

While the datepicker pop up is displayed having the hour set to 12 and AM the input field's hour portion should update to a "00" like the 1-11 hours have +12 added onto them when PM is selected.

Actual result

The hour portion of the input field remains a 12 even if you select AM.

System information (as much as possible)

Joomla 3.7.5
PHP Version 7.0.22-0ubuntu0.16.04.1
Apache Version Apache/2.4.18 (Ubuntu)

Additional comments

I have tested this on a 3.8.0 build, and the error persists.

avatar GCLW GCLW - open - 11 Sep 2017
avatar joomla-cms-bot joomla-cms-bot - labeled - 11 Sep 2017
avatar brianteeman
brianteeman - comment - 12 Sep 2017

Sorry but you are not correct. There is no such thing as 00:00 am

https://en.wikipedia.org/wiki/12-hour_clock

avatar franz-wohlkoenig franz-wohlkoenig - change - 12 Sep 2017
Status New Information Required
avatar GCLW
GCLW - comment - 12 Sep 2017

Correct there is no such thing, but I never stated that either.
Brian please look at my screen shot.
When you select 3 PM, the input field above shows the (24 hour time) 15:00:00
When you select 12 AM the input field above should show the (24 hour time) as 00:00:00

avatar dgt41
dgt41 - comment - 12 Sep 2017

@GCLW setting the time format parameter is the one part of the equation, the other part is to provide the correct format. This is not done automatically by the field

avatar GCLW
GCLW - comment - 12 Sep 2017

It is done by the Java Script. When you have either [1-11] selected as the hour in the time picker, and if you flip back and forth AM or PM, in the date/time field above the hour has +12 added to it when PM is selected.
Look at the screen shot.

avatar GCLW
GCLW - comment - 12 Sep 2017

screen shot 2017-09-12 at 16 11 26
This might help.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/17938.

avatar dgt41
dgt41 - comment - 12 Sep 2017

%H - Hour of the day, 24-hour clock, zero-padded (00..23)
%I - Hour of the day, 12-hour clock, zero-padded (01..12)

Again your format is wrong

avatar GCLW
GCLW - comment - 12 Sep 2017

The "timeformat" attribute dictates how the drop-down menus will be in the Calendar itself.

The "format" attribute dictates what the formatting will look like in the input field itself. I am using %H already that is why when 3 PM is selected 15:00:00 is displayed in the input field.

If I am wrong why is 3 PM correctly being converted into 15:00:00 ?


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/17938.

avatar GCLW
GCLW - comment - 21 Sep 2017

Working with the uncompressed javascript file
media/system/js/fields/calendar.js

Line 181
} else if (/am/i.test(ampm.value) && hours === 12) {
Needs to be == 12 when doing the comparision

Line 751
pm = (altDate.getHours() > 12);
Needs to be >= 12 due to altDate.getHours() returning [0-23] which makes 12 a pm hour

Line 969
hoursEl.value = hrs;
Do a condition chech of !this.params.time24 and if hrs == 00 hoursEl.value = 12 else hoursEl.value = hrs
if (!this.params.time24) { hoursEl.value = (hrs == "00") ? "12" : hrs; } else { hoursEl.value = hrs; }

Those are the changes I made.
This is my final comment on the issue.

avatar brianteeman
brianteeman - comment - 4 Oct 2017

ah i understand you now - sorry for being thick

I will look at making a PR to fix this

avatar brianteeman brianteeman - change - 4 Oct 2017
Status Information Required Closed
Closed_Date 0000-00-00 00:00:00 2017-10-04 23:38:55
Closed_By brianteeman
avatar brianteeman brianteeman - close - 4 Oct 2017
avatar brianteeman
brianteeman - comment - 4 Oct 2017

Closed see #18240 18240

Add a Comment

Login with GitHub to post a comment