Shoutbox

[split] Daylight savings time bug - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: General (/forumdisplay.php?fid=11)
+---- Forum: Forum & Website (/forumdisplay.php?fid=13)
+----- Thread: [split] Daylight savings time bug (/showthread.php?tid=33958)

RE: Daylight savings! :banana: by CookieRevised on 11-01-2004 at 06:50 PM

Fishy already knows this (and he was not happy hearing it :p), but there is major bug with DST in mybb, Invision Power Board (and possible all other boards too)....

Posttimes of the past are also changed when you set/unset DST in your profile. This is plain wrong. When a post has been posted 10 days ago at 10am GMT, it still is posted at 10am 10 days ago, not at 9am or 11am...

Switching on/off the DST shouldn't change the times prior to the switching on/off!

The problem is: Posttimes are calculated when you view the thread. But with this calculation, the current DST-setting is also taken in account, which is wrong to do. The DST should be saved together with the post, not calculated afterwards.

What should be done is, eg:
* DST is ON for me. If I post a message on september 1st, at 10am GMT (my localtime), then 11am GMT should be saved, not 10am GMT, because it IS actually 11am GMT for me.
* DST is OFF for me. If I post a message on september 1st, at 10am GMT (my localtime), then 10am GMT should be saved, as normal.

Afterwards, the calculation/convertion to the localtime of the reader is still calculated of course, but without the DST's taken in account (of either poster and reader).

Because for me the message was still posted respectivly at 11am and 10am on september 1st. For the reader (even regardless of his DST setting) this also still would be, eg: 6am GMT-5 and 5am GMT-5, september 1st...


RE: Daylight savings! :banana: by WDZ on 11-01-2004 at 06:57 PM

quote:
Originally posted by CookieRevised
and possible all other boards as well
This is the key sentence. :D

Seriously, I don't think the hassle of storing DST values and complicating the calculations is worth the benefit. Just thinking of coding such a feature makes my brain go "arrrghhh!!!!!!!1" :p
RE: Daylight savings! :banana: by CookieRevised on 11-01-2004 at 07:06 PM

quote:
Originally posted by WDZ
This is the key sentence.
hmmm, so??? In fact, it should encourage you, making this the first board which integrates DST correctly!! :undecided:

Seriously, there is nothing complicated with it.

Instead of storing 10am when DST is on, store 11am.
If DST is off then store 10am (as useuall):

And also remove the DST calculation for when the times are calculated when you view posts!...

When the posttimes are stored:
code:
posttime = "10:00"
IF DST = on Then
  posttime = posttime + 1
End If
It is as simple as this....



In fact, all this makes that the calculation for converting the times to the localtime of the reader is made much simpler (and slightly faster, cause DST settings doesn't need to be looked anymore when people view threads).



(PS: the key sentence should be: you can't change dates/times in the past, unless you have the timemachine from professor Barabas -dutch people know what I'm talking about :p-)
RE: Daylight savings! :banana: by WDZ on 11-01-2004 at 07:16 PM

I don't get it. My brain isn't capable of absorbing such things, especially after only 5 hours of sleep. :p

Why store the DST setting of the poster? What if the DST setting of the viewer is different from that? :-/

quote:
hmmm, so???
The fact that nobody else has done it means that I shouldn't be expected to do it, and it's a good excuse not to. :p
RE: Daylight savings! :banana: by CookieRevised on 11-01-2004 at 08:23 PM

quote:
Originally posted by WDZ
Why store the DST setting of the poster?
Because it is the correct way... Because, his posting time depends on his DST setting, not on mine...

quote:
Originally posted by WDZ
What if the DST setting of the viewer is different from that?
That's the point, it doesn't matter :D If someone has posted a message at 10am on Sept 1st, that would still be 10am Sept 1st regardless if I'm in DST now or not. Like I said, you can't change times in the past. 10am in the past is 10am... that time doesn't change when you set DST now or not.

PS: get some sleep first ;)

quote:
Originally posted by WDZ
The fact that nobody else has done it means that I shouldn't be expected to do it, and it's a good excuse not to.
No, it means that everybody copied from eachother without thinking because they cba to think about it and it was already late :refuck:
RE: [split] Daylight savings time bug by WDZ on 11-01-2004 at 08:37 PM

quote:
Originally posted by CookieRevised
Because it is the correct way... Because, his posting time depends on his DST setting, not on mine...
:huh:

The time shown by the post is the time it was in the viewer's time zone when the post was made.

If it's 3:35 here, and 9:35 in Belgium, at the moment you post, the time shown to me must be 3:35, regardless of what your DST setting is. :^)
RE: [split] Daylight savings time bug by CookieRevised on 11-01-2004 at 08:57 PM

quote:
Originally posted by WDZ
If it's 3:35 here, and 9:35 in Belgium, at the moment you post, the time shown to me must be 3:35, regardless of what your DST setting is.
no, (I underlined the things which are related)...

If it is 9:35 in Belgium at the time I posted the message, that time depends on the DST setting of the time I posted the message.

In other words it can be 9:35 (DST on) for me when I posted the message, yet 8:35 will be stored (the method used now). And thus you will see 2:35 instead, thus this is wrong because at the time of posting 9:35 for me was 3:35 for you...

You can't calculate the DST difference when you view the time, you need to calculate it when you store the time.



Another way of looking at it:

My DST is enabled. I'm viewing a thread and the first post is posted at 12:43.
This means this is posted right after midday in the timeframe of a day.

When I need to disable my DST setting, and I look again at that post, it suddenly is posted before midday (11:43)...

This isn't correct as times in the past can not suddenly change.
RE: [split] Daylight savings time bug by WDZ on 11-01-2004 at 09:26 PM

quote:
Originally posted by CookieRevised
In other words it can be 9:35 (DST on) for me when I posted the message, yet 8:35 will be stored (the method used now). And thus you will see 2:35 instead, thus this is wrong because at the time of posting 9:35 for me was 3:35 for you...
Based on your profile, you posted your reply at 9:57 PM (your time). The time I see is 3:57 PM. That's the correct time. :-/

Blah... I hate it when I can't understand something like this... I don't know who's wrong... :p

quote:
I underlined the things which are related
Well, the "9:35" is irrelevant... I only included it as an example. The point is that if it's 3:35 here when you post, the time shown to me is 3:35, and your DST setting doesn't matter.

quote:
My DST is enabled. I'm viewing a thread and the first post is posted at 12:43.
This means this is posted right after midday in the timeframe of a day.

When I need to disable my DST setting, and I look again at that post, it suddenly is posted before midday (11:43)...
That part (the problem) I understand. It's the solution I'm having trouble with.

quote:
This isn't correct as times in the past can not suddenly change.
Well, they can when a new time zone offset is applied to them. :p The DST option effectively increments your time zone setting by 1.
RE: [split] Daylight savings time bug by CookieRevised on 11-01-2004 at 09:44 PM

quote:
Originally posted by WDZ
Well, the "9:35" is irrelevant... I only included it as an example. The point is that if it's 3:35 here when you post, the time shown to me is 3:35, and your DST setting doesn't matter.
No, the time shown to you wouldn't be 3:35, but 2:35, because DST wasn't saved with the posttime. If it was saved (like I suggest) you _will_ see 3:35, but only when it is saved _with_ the posttime, not when it is calculated when you view the time... see PS note below

quote:
Originally posted by WDZ
Based on your profile, you posted your reply at 9:57 PM (your time). The time I see is 3:57 PM. That's the correct time.
Because DST is off atm. This isn't a valid example because DST = 0 atm, so regardless when you add it at storing time or calculate it afterwards, the result will be the same ;)

quote:
Originally posted by WDZ
Well, they can when a new time zone offset is applied to them.
No, the GMT time must still be the same...
If you apply another timezone, the actual time (universal time) isn't changed.
5 GMT = 4 GMT-1, but UTC is still 5.


PS: I'm getting a headache now too :p

maybe my solution isn't the solution afterall, but there sure is a problem with the viewing times........

wild thought (without much thinking because of late hour (how irronic :P) and headache): what if the times are calculated when viewed, but only take in account DST for the posts that were actually posted when DST was on? <= doesn't make much sense now, I'll explain further tommorow (or delete it) :p
RE: [split] Daylight savings time bug by surfichris on 11-06-2004 at 03:10 AM

Bah. Cookie, there's one thing you don't understand about it. We can't store the value of DST for EVERY user for EVERY post. Thats x*y = huge z. You don't understand how the php time() function works - it stores the time since unix epoch. It does not store GMT time. Its stored as a numerical (bigint) value in the database. Time since epoch is like GMT time, but it is not GMT time.

Here's the solution i've thought up. A new column in the users table along side the 'dst' one, called 'dstchanged' which stores the time the dst value was last changed.

When calculating post/time stamps it compares the values and if time > dstchanged & dst = on, we'll change the value accordingly, else we don't do anything to the time.. Something like that.