Author |
Topic |
|
Shaggy
Support Moderator
Ireland
6780 Posts |
Posted - 30 March 2009 : 08:06:39
|
I'm trying to figure out how to handle DST in my RSS feeds and keep confusing myself. If it started and ended on specific dates every year then it would be a simple matter of just checking what the date is and appending the appropriate time zone (GMT or +0100 in my case) but, because the dates are different every year, I just can't figure out an effective way of handling it. Any suggestions?
|
Search is your friend “I was having a mildly paranoid day, mostly due to the fact that the mad priest lady from over the river had taken to nailing weasels to my front door again.” |
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
Posted - 30 March 2009 : 08:14:08
|
just leave them as GMT and tell everyone that they are GMT
Doesn't your RSS get it's time from the server which should update itself automatically anyway. |
|
|
Shaggy
Support Moderator
Ireland
6780 Posts |
Posted - 30 March 2009 : 09:25:16
|
Yeah, I was perfectly happy to leave them as GMT but a site in America that's pulling in one of my feeds converts the timestamps to their own local time so anything with a GMT timezone that's actually DST is being converted to an hour in the future and they're not displaying it. Looking ahead, I can see this being a problem on a site I've got lined up for next month which is expected to have a large international audience.
The date and time is being pulled from my database - where it's stored the same way we store dates here (yyyymmddhhmmss) - and then being converted to a valid date/time string so I've no way of telling if the time for each record in the database is GMT or DST.
|
Search is your friend “I was having a mildly paranoid day, mostly due to the fact that the mad priest lady from over the river had taken to nailing weasels to my front door again.” |
|
|
SiSL
Average Member
Turkey
671 Posts |
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
Posted - 30 March 2009 : 12:32:28
|
quote: Originally posted by Shaggy
Yeah, I was perfectly happy to leave them as GMT but a site in America that's pulling in one of my feeds converts the timestamps to their own local time so anything with a GMT timezone that's actually DST is being converted to an hour in the future and they're not displaying it. Looking ahead, I can see this being a problem on a site I've got lined up for next month which is expected to have a large international audience.
The date and time is being pulled from my database - where it's stored the same way we store dates here (yyyymmddhhmmss) - and then being converted to a valid date/time string so I've no way of telling if the time for each record in the database is GMT or DST.
1) a GMT time can not be a DST time, it is not possible 2) The forum stores time based on the server +/- whatever you have set in your forum admin, and the servers time will be gmt or dst depending where it is, and will update itself automatically.
3) the problem is infact with them, your RSS is updating itself and displaying times in DST as it should, it is their code that has buggered it up since it does not know that the clocks have changed not you. |
|
|
Shaggy
Support Moderator
Ireland
6780 Posts |
Posted - 30 March 2009 : 12:51:55
|
quote: Originally posted by HuwR 1) a GMT time can not be a DST time, it is not possible
That's the problem. At the moment, all the times in my feed have GMT appended to them which is fine for anything posted last week but anything posted this week should have +0100 instead of GMT as the timezone because, as you say, DST is not GMT. The times are inserted into the database based on the current server time (GMT last week, DST this week) so the problem is arising when I pull them and just throw GMT on the end; this site checks the timezone in the timestamp and adjusts it accordingly to display it in their local time.
For example:
If I posted an article at 17:51 last Friday, it would be stored in the database as 20090327175100 and, when I then pulled it from the database and ran it through the function below, it would correctly display as Fri, 27 Mar 2009 17:51:00 GMT.
If I made a post at the exact same time today (now), it would also be stored as 20090330175100 so, when I pull it from the database and run it through the same function, it would be displayed incorrectly as Mon, 30 Mar 2009 17:51:00 GMT which is an hour into the future. It should display as either Mon, 30 Mar 2009 17:51:00 +0100 or Mon, 30 Mar 2009 16:51:00 GMT
Here's the function I run the string through: |
Search is your friend “I was having a mildly paranoid day, mostly due to the fact that the mad priest lady from over the river had taken to nailing weasels to my front door again.” |
Edited by - Shaggy on 30 March 2009 12:53:10 |
|
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
Posted - 30 March 2009 : 13:04:52
|
okay, I see your problem, can't you just do a date check and if the date is > 28/03 then take an hour off the time.
you could try SISL suggestion, but you will need to change his code as ActiveTimeBias is stored in Hex not decimal, so the value you get back will be ffffffc4 which is hex for -60 it should indeed return it in minutes, even though it is stored as hex |
|
|
SiSL
Average Member
Turkey
671 Posts |
|
HuwR
Forum Admin
United Kingdom
20584 Posts |
Posted - 31 March 2009 : 01:43:33
|
UTC is GMT |
|
|
SiSL
Average Member
Turkey
671 Posts |
|
Shaggy
Support Moderator
Ireland
6780 Posts |
Posted - 31 March 2009 : 07:21:09
|
SiSL, GMT does not change to incorporate DST.
Thanks for that wee script; I'll be using it from now on to make sure all times are inserted into my databases as GMT.
Huw, I'm using a date check on the site I'm working on at the moment as a stop gap solution. The problem with using it on the site which is causing issues at the moment is that that site is over 2 years old now so I'd need to include a lot of checks not to mention include a new check every year. Ideally, what I'm looking for (and what is the source of my confusion in the original post) is a way to calculate, each year:quote: "... the period beginning at one o'clock, Greenwich mean time, in the morning of the last Sunday in March and ending at one o'clock, Greenwich mean time, in the morning of the last Sunday in October."
With SiSL's script, I won't need to do this for any sites I build in the future but would still need the option just in case I'm working on a server that won't allow me to read the registry. I found this PERL script this morning so I'm going to take a whirl at translating that; looks straightforward enough even though I don't "speak" PERL.
|
Search is your friend “I was having a mildly paranoid day, mostly due to the fact that the mad priest lady from over the river had taken to nailing weasels to my front door again.” |
|
|
SiSL
Average Member
Turkey
671 Posts |
|
Shaggy
Support Moderator
Ireland
6780 Posts |
Posted - 31 March 2009 : 08:13:32
|
Success!
I was halfway through translating that PERL script when I found an ASP version
My timestamp function now looks like this:
The only minor problem with it is that anything posted within an hour after the clock goes back will be +0100 when it should be GMT but there's no way around that without storing the timezone is the database and I think I can safely say that none of my clients are going to be posting articles to their websites at that time.
Thanks to you both for helping me brainstorm this one quote: Originally posted by SiSL As long as IIS run with System users, I think you'd able to access that key since it is used by most system services in Windows.
I'll keep that in mind. It's rare these days that I'm not working on my own server but it's good to have both options to fall back on, just in case
|
Search is your friend “I was having a mildly paranoid day, mostly due to the fact that the mad priest lady from over the river had taken to nailing weasels to my front door again.” |
Edited by - Shaggy on 31 March 2009 08:14:13 |
|
|
|
Topic |
|
|
|