24-hour clock

24-hour clock

by Ole Hartvigsen -
Number of replies: 6
Hi,

In Administration / Appearance / Calendar a time format setting is available, i have chosen the 24 hrs calendar.

But in the face-to-face session overview screen the time format is incorrect, it shows the am/pm time. When adding or editing a session, the time format is correct.

Can anyone help me to fix that?

Thanks

Ole
Average of ratings: -
In reply to Ole Hartvigsen

Re: 24-hour clock

by François Marier -
Hi Ole,

Thanks for reporting this. While you were looking at the wrong setting (the Calendar settings are specific to the Calendar component of Moodle), you made me look at something that hadn't been considered before.

I have fixed the date/time display in the Face-to-face module and so if you download the latest version now, it should have the fix for that.

Now, to answer your question: to change the way that dates and times are displayed globally in Moodle, you need to modify the "strftime" series of strings in the language pack you are using. So for example, to change the english-language Moodle to display 24-hour time, you need to edit this file:

/moodle/lang/en_utf8/langconfig.php

and replace:

$string['strftimetime'] = '%%I:%%M %%p';

with this:

$string['strftimetime'] = '%%H:%%M';

Francois
In reply to François Marier

Re: 24-hour clock

by Ole Hartvigsen -
Hi Francois,

Thanks for looking at it.

I'm using the default danish language pack. In the langconfig.php file this setting is already made:

$string['strftimetime'] = '%%H:%%M';

On the latetest build of the f2f activity I still get this problem. On the session overview page the time does not show correct. In this example the session is defined as running from 09:00 to 17:00 hrs:

Free Image Hosting at www.ImageShack.us

When adding or editing a session, the time format is correct.



Cheers

Ole
.
In reply to Ole Hartvigsen

Re: 24-hour clock

by François Marier -
There must be a string that's overwriting the settings in lang/da_utf8/langconfig.php.

Here's a way to find out. Add the following line to mod/facetoface/lib.php, at the top of the "facetoface_print_sessions" function:

  print '<h1>' . get_string('strftimetime') . '</h1>';

This will display the format that is being picked up Moodle directly aboving the "Upcoming sessions" heading.

Then, you can hunt for the places where the 'strftimetime' string is defined by searching the contents of files.  On Linux, you can do this from the top-level Moodle directory:

  grep -r "\['strftimetime'\]" *

For example, I get this returned:

  lang/en_utf8/moodle.php:$string['strftimetime'] = '%%I:%%M %%p';
  lang/en_utf8/langconfig.php:$string['strftimetime'] = '%%I:%%M %%p';

I changed both strings to be different values so that I could tell which one had priority over the other.
In reply to François Marier

Re: 24-hour clock

by Ole Hartvigsen -
Hmm.. strange times...

I've searched through all the source code, I can not find the string. Could it be stored in the database?
In reply to Ole Hartvigsen

Re: 24-hour clock

by Ole Hartvigsen -
Got a bit closer to finding the error.

In the language files the timeformat is defined as:
$string['strftimetime'] = '%%H:%%M';

However, when i print the timeformat in the face-to-face facetoface_print_sessions function, the result is:

%H:%M

I've searched the sourcecode, and the strftimetime string is not changed anywhere i can find.

Any suggestions on where i could look?

Ole