|
[
Permalink
| « Hide
]
Mathieu Petit-Clair added a comment - 19/Mar/08 02:53 PM
Eloy had a look at this and it appears that usergetdate() is using the current logged-in user ($USER) timezone (or the site timezone, I suppose) to make the calculations. He sent me a patch that mostly fixes this issue, but I still have a problem with it. More news as soon as possible...
yes .. usergetdate() is using the current logged-in user ($USER) timezone, but I use the same function and pass diferent parameter,
even so ... if I change the timezone from "edit profile" and logout then login .. there is 1 hour difference in north America stats and canada. I commited a fix sent by Eloy.
I also have update timezone info to latest package available (2008a -
Ciao Danya, can you confirm that this is fixed for you?
I still have complaints from my users ... for example ... "America/New_York" .. is says that there is 5 hours difference "gmtoff = -300" for 2007 .. and it should be 4 hours. is that right?
Thanx alot. BTW .. I just updated the timezone profile from admin front end.
Hi Danya:
New York standard time (gmtoff) is -5 hours (300). And there is one DST (dstoff) in action since March 9th, of +1 hour (60). And that's exactly what the timezones information says. Also, I've tried the usergetdate() function, asking for America/New_York times and results obtained from Moodle are exactly the same than the ones at: http://www.timeanddate.com/worldclock/city.html?n=179 So... what are you getting? Correct or incorrect results? Also... note that it isn't a matter of updating the timezones from admin. Also you need to update your Moodle to the latest 1.8.5+ or 1.9+ release to get the usergetdate() (and other) functions working properly. Have you?
Ciao Thanx alot Eloy for your quick response ...
I just installed 1.9+ (I didn't before) and checked the function .. when I tried this: $mktime = mktime(14, 0, 0, 4 ,09, 2008); I get 9:00 AM .. but as the site (http://www.timeanddate.com/worldclock/city.html?n=179 Is that right? Ah, no! That's pretty incorrect (in order to correctly handle timezones and DSTs!)
You need to use Moodle functions to guarantee that everything is ok, without mixing php functions (mktime, date...) with moodle functions (usergetdate). So, to get the GMT timestamp of one date... you need to execute: $timestamp = make_timestamp(2008, 4, 9, 14, 0, 0, 'America/New_York'); And then you can handle that GMT timestamp as you prefer, for example:
But, as you see, ALWAYS using Moodle functions that will handle both the timezone and the dst properly. Note also, that if you doesn't use the timezone parameter in the functions above... then the user timezone will be used automatically (normal Moodle behaviour). Ciao Thanks alot Eloy .. and sorry to be late ..
as you said .. I installed the new time functions in (moodlelib.php) .. I can't replace all files because the semester not finished yet. for this code: $timestamp = make_timestamp(2008, 4, 9, 14, 0, 0, 'America/New_York'); the result will be: but if you write: $timestamp = make_timestamp(2008, 4, 9, 14, 0, 0); // WITHOUT TIMEZONE the result will be: Really thanx alot Eloy. Hi Danya,
I really don't understand why you say that this is wrong: $timestamp = make_timestamp(2008, 4, 9, 14, 0, 0, 'America/New_York'); the result will be: It's perfect IMO. If you request one timestamp for NY and then print it (also for NY) time must be EXACTLY the original one. It's a trivial case. Problem arrive when you MIX functions using and not using the timezone explicitly, because then, your server timezone is used by default. So, your second example is really dependent of your server timezone, because you request one timestamp using your server timezone (4 hours before NY) and then want to print what time is in NY (4 hours after you). I really don't understand why you say the 1st example is wrong, one NY timestamp will show one NY userdate, so they MUST be equal (in fact something would be really wrong if that caused different times to be shown). Ciao Hi ..
oh .. sorry .. I understand your example in pre-comment in a wrong way. Thanx a lot for clarification. Hi,
great, it's really not easy to explain nor to understand... thanks! Ciao |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||