userdate() has issue with Pacific/Kiritimati Moodle 1.9.1

userdate() has issue with Pacific/Kiritimati Moodle 1.9.1

by Alex Parsy -
Number of replies: 2

When I print a date at my EST(New York) 10:48 PM  I get wrong time. Actually it prints my localtime:   

$usertime = userdate(gmmktime(), get_string('strftimedaydatetime'), "Pacific/Kiritimati" );

echo $usertime  yields:     "09/10 22:48"

 

When I use the below code, the time is correctly displayed:

$userDateTime = new DateTime(null, new DateTimeZone("Pacific/Kiritimati"));
$usertime = $userDateTime->format('m/d H:i');

echo $usertime yields:    "09/10 16:48"

 

Tracing through the code shows the issue here at function "userdate"

 

 

Average of ratings: -
In reply to Alex Parsy

Re: userdate() has issue with Pacific/Kiritimati Moodle 1.9.1

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

So, are you suggesting that the >13 on the next line be changed to something else, like >20?

I believe the only special value we use in this API is 99, so changing the cut-off to 20 should be safe, but I don't feel confident I know enough about this API to be sure.

(I think it this was changed, we might also need to change a few other places. For example PARAM_TIMEZONE also enforces the 13 limit.)

Average of ratings: Useful (1)
In reply to Tim Hunt

Re: userdate() has issue with Pacific/Kiritimati Moodle 1.9.1

by Alex Parsy -

I am guessing +14 is the maximum offset from UTC so changing to 20 should about cover it. I just wasn't sure how this breaks code. I am working off of 1.9.1 and I don't see a PARAM_TIMEZONE variable in the codebase.

I created a bug in tracker for it.

Thank you for the suggestion to fix.

A.