TzInfo and DST and UTC to Easter convert help

We created a calendar on ruby on rails using the TzInfo add-in. The
users set a timezone in their preference and all dates/times are saved
to the DB in UTC. This worked great up until March 8/9 for Eastern
because of the DST change and we moved ahead one hour. Therefore, if
an entry saved to the db for 8:40am Eastern it was put in the system
as 5 hours ahead. However, it has now changed to 4 hours ahead and
all new entries saved for this time period are off. If an event
started on the 7th of March and went to the 10th of March, everything
prior to DST is fine but everything else is off by an hour. How do I
compensate for this extra hour? I am sure it will be fine in a few
weeks when UTC reflect their DST. I am running TzInf v0.3.6, RoR
2.0.2 and gems 1.0.1.

Is there a difference between UTC and GMT?


private
def setdatetoutc(enddateyn)
if @appointment.StartTime!=nil and @appointment.StartTime.to_s!=’’
@tempsdated=Time.parse(@appointment.StartDate.to_s)
@tempsdatet=Time.parse(@appointment.StartTime.to_s)
@tempsdate=Time.local(@tempsdated.to_date.strftime(’%Y’),
@tempsdated.to_date.strftime(’%m’), @tempsdated.strftime(’%d’),
@tempsdatet.strftime("%H"), @tempsdatet.strftime("%M"),
@tempsdatet.strftime("%S"))

end

if @appointment.EndTime!=nil and @appointment.EndTime.to_s!=’’

@tempedated=Time.parse(@appointment.StartDate.to_s)
@tempedatet=Time.parse(@appointment.EndTime.to_s)
@tempedate=Time.local(@tempedated.strftime(’%Y’),
@tempedated.strftime(’%m’), @tempedated.strftime(’%d’),
@tempedatet.strftime("%H"), @tempedatet.strftime("%M"),
@tempedatet.strftime("%S"))
end

if enddateyn==‘y’
if @appointment.EndDate!=nil and @appointment.EndDate.to_s!=’’
@tempaedated=Time.parse(@appointment.EndDate.to_s)
@tempaedatet=Time.parse(@appointment.EndTime.to_s)
@tempaedate=Time.local(@tempaedated.strftime(’%Y’),
@tempaedated.strftime(’%m’), @tempaedated.strftime(’%d’),
@tempaedatet.strftime("%H"), @tempaedatet.strftime("%M"),
@tempaedatet.strftime("%S"))
end
end

if @tempsdate.to_s!=""
@[email protected]_to_utc(@tempsdate)
@[email protected]_to_utc(@tempsdate)
end

if @tempedate.to_s!=""
@[email protected]_to_utc(@tempedate)
@[email protected]_to_utc(@tempedate)
end

if @tempaedate.to_s!=""
@[email protected]_to_utc(@tempaedate)
end

end


private
def setdatetolocal(enddateyn)

if @appointment.StartTime!=nil and @appointment.StartTime.to_s!=’’

@tempsdated=Time.parse(@appointment.StartDate.to_s)
@tempsdatet=Time.parse(@appointment.StartTime.to_s)
@tempsdate=Time.local(@tempsdated.to_date.strftime(’%Y’),
@tempsdated.to_date.strftime(’%m’), @tempsdated.strftime(’%d’),
@tempsdatet.strftime("%H"), @tempsdatet.strftime("%M"),
@tempsdatet.strftime("%S"))

end

if @appointment.EndTime!=nil and @appointment.EndTime.to_s!=’’
@tempedated=Time.parse(@appointment.StartDate.to_s)
@tempedatet=Time.parse(@appointment.EndTime.to_s)
@tempedate=Time.local(@tempedated.strftime(’%Y’),
@tempedated.strftime(’%m’), @tempedated.strftime(’%d’),
@tempedatet.strftime("%H"), @tempedatet.strftime("%M"),
@tempedatet.strftime("%S"))

end

if enddateyn==‘y’
if @appointment.EndDate!=nil and @appointment.EndDate.to_s!=’’
@tempaedated=Time.parse(@appointment.EndDate.to_s)
@tempaedatet=Time.parse(@appointment.EndTime.to_s)
@tempaedate=Time.local(@tempaedated.strftime(’%Y’),
@tempaedated.strftime(’%m’), @tempaedated.strftime(’%d’),
@tempaedatet.strftime("%H"), @tempaedatet.strftime("%M"),
@tempaedatet.strftime("%S"))

end
end

if @tempsdate.to_s!=""
@[email protected]_to_local(@tempsdate)
@[email protected]_to_local(@tempsdate)
end

if @tempedate.to_s!=""
@[email protected]_to_local(@tempedate)
@[email protected]_to_local(@tempedate)
end

if @tempaedate.to_s!=""
@[email protected]_to_local(@tempaedate)
end

end


On 9 Mar 2008, at 13:07, David wrote:

compensate for this extra hour? I am sure it will be fine in a few
weeks when UTC reflect their DST. I am running TzInf v0.3.6, RoR
2.0.2 and gems 1.0.1.

Is there a difference between UTC and GMT?
Technically yes, in practical senses no. If you care about things like
leap seconds being added because the rotation of the earth is slowing,
then yes.

@tempsdated.to_date.strftime(’%m’), @tempsdated.strftime(’%d’),
@tempsdatet.strftime("%H"), @tempsdatet.strftime("%M"),
@tempsdatet.strftime("%S"))

What timezone is your server using? That will affect the result of
these calls of Time.local an strftime
Also I can’t help but think that this all looks very complicated.

Fred

end

The server is using UTC. This works fine up until the date of DST
switchover. Then it all goes haywire.