On 9 Mar 2008, at 13:07, David wrote:
>
> 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?
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.
>
>
> #
> -------------------------------------------------------------------
> 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"))
>
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
>
> 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!=""
> @appointment.StartDate=@tz.local_to_utc(@tempsdate)
> @appointment.StartTime=@tz.local_to_utc(@tempsdate)
> end
>
> if @tempedate.to_s!=""
> @appointment.TZEndDate=@tz.local_to_utc(@tempedate)
> @appointment.EndTime=@tz.local_to_utc(@tempedate)
> end
>
> if @tempaedate.to_s!=""
> @appointment.EndDate=@tz.local_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!=""
> @appointment.StartDate=@tz.utc_to_local(@tempsdate)
> @appointment.StartTime=@tz.utc_to_local(@tempsdate)
> end
>
> if @tempedate.to_s!=""
> @appointment.TZEndDate=@tz.utc_to_local(@tempedate)
> @appointment.EndTime=@tz.utc_to_local(@tempedate)
> end
>
> if @tempaedate.to_s!=""
> @appointment.EndDate=@tz.utc_to_local(@tempaedate)
> end
>
> end
> #
> -------------------------------------------------------------------
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---