Daylight Saving Time in RSS - Postet den (1445 Views)
Support Moderator
Shaggy
Innlegg: 6780
6780
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.”
   
 Sidestørrelse 
Postet den
Forum Admin
HuwR
Innlegg: 20611
20611
just leave them as GMT and tell everyone that they are GMT smile

Doesn't your RSS get it's time from the server which should update itself automatically anyway.
Postet den
Support Moderator
Shaggy
Innlegg: 6780
6780
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.”
Postet den
Average Member
SiSL
Innlegg: 671
671
You might use something like that:

Code:

Function RSSTime(strTime)

od = strToDate(strTime)
set oShell = CreateObject("WScript.Shell")
atb = "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation\ActiveTimeBias"
offsetMin = oShell.RegRead(atb)
RSSTime = dateadd("n", offsetMin, od)
End Function
Postet den
Forum Admin
HuwR
Innlegg: 20611
20611
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 smile 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.
Postet den
Support Moderator
Shaggy
Innlegg: 6780
6780
Originally posted by HuwR 1) a GMT time can not be a DST time, it is not possible smile
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:
Code:
function timestamp(str)
if isnull(str) or len(str)=0 then exit function
timestamp=mid(str,7,2)&"/"&mid(str,5,2)&"/"&left(str,4)
if isdate(timestamp) then
timestamp=cdate(timestamp)
timestamp=weekdayname(weekday(timestamp),true)&", "&day(timestamp)&" "&monthname(month(timestamp),true)&" "&year(timestamp)&" "&mid(str,9,2)&":"&mid(str,11,2)&":"&right(str,2)&" GMT"
else
timestamp=""
end if
end function
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.”
Postet den
Forum Admin
HuwR
Innlegg: 20611
20611
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
Postet den
Average Member
SiSL
Innlegg: 671
671
Well, I use it because I'm also sick off invalid times due to different locales and daylight savings... That will help you return as "UTC" time at least, not GMT, which is globally understood by RSS readers and converted to their locales easier.
So after getting ActiveTimeBias with the function I gave you (which will return you real datetime, you simply do function to convert it like "Mon, ...." but instead of "+0100", or "GMT" at end, you will write " UT"


Postet den
Forum Admin
HuwR
Innlegg: 20611
20611
UTC is GMT
Postet den
Average Member
SiSL
Innlegg: 671
671
As far as I know, GMT gets effected by Daylight Savings Time while UT is absolute time.
In the end, with UT prefix, no need to add any +0100 etc. suffixes in the end of RSS.
Postet den
Support Moderator
Shaggy
Innlegg: 6780
6780
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:
"... 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.”
Du må legge inn en melding