Hi Dave,
if all of the times entered into your system are to have the same
timezone and you don''t need to perform date math across timezones then
I''d say the issue of daylight savings time (DST) might safely be
ignored for the time being.
I say "*might* be safely ignored" because there are still issues to
consider if you''re doing date math. Like (IIRC) what is the difference
between 01:15 AM and 01:16 AM on the last Sunday in October in London?
Is it 1 minute or 61 minutes?
This is most definitely an issue for ''parsed'' dates but may
not be an
issue for dates generated by Time.now() and stored in the DB. I''m
unsure because I don''t know whether your DB will correctly convert a
date in the "Europe/London" TZ to the correct UTC value.
You''ll need
to experiment to make sure:
Off the top of my head, the first thing to try is to set the TZ
environment variable for your database to be "UTC" and set TZ for your
rails app to be "Europe/London" (I''m assuming you''re
deploying on a
POSIX system). Then, muck around with the system dates and see how
your software copes with DST crossovers.
If your times are out by an hour then you''ll have to use
"Europe/London" for both the db and rails. But then the
''parsed'' dates
problem (above) will occur for values stored in the db as well.
A longer-term and imho more correct solution is to set TZ for your db
and rails app to be UTC and format/parse your dates according to an
application-wide or user-specific POSIX timezone. I favor this
solution because if you have a world-wide user base it allows you to
accept and display times according to a user-preferred timezone.
Alas, that''s easier said than done. I managed to hack together some
timezone code that was DST aware but it''s slow and ugly and not ready
for general consumption. Jamis Buck has mentioned that DST aware
timezones in rails is on his stack of things to do but I can''t say how
far along it is.
I hope this helps,
Trevor
On 6-Sep-05, at 12:44 PM, Dave Silvester wrote:
> François Beausoleil wrote:
>> I don''t know how to do it, but wouldn''t it be better
if you stored
>> the times in UTC+0000, and reformatted when ready to show to the user
>> ?
>
> Quite possibly, but then do I potentially have to deal with other
> issues, such as knowing when to begin summer time and so on? Or is
> there some automatic way I could store them as UTC and then say "make
> this into a time appropriate for the UK at that point in time", or
> similar?
>
> In a way, this already seems to happen - Ruby (or Rails, but I suspect
> it''s Ruby itself) handles the time zones completely automatically,
> which is going to be very useful. I suspect that possibly the times
> are already represented internally in terms of UTC with a timezone
> offset?
>
> In fact, it almost feels like I may have to fight against Rails to get
> it not do do this automatically? In a way, since my app is already
> working on my UK dev box and taking account of time zones quite
> nicely, I''d really quite like to just tell the app "you live
in the UK
> so behave like it". Whether that means 11pm pub closing time,
> fighting into the early hours, drinking tea, eating curry, not wanting
> to make a fuss and complain about bad service and so on... those are
> entirely optional extras! ;-)
>
> Still, I''m open to any suggestions, and will certainly consider
yours
> if my issues above turn out to be insignificant. The tea and fighting
> can wait until my next development iteration, merci monsieur!
>
> BTW, I got your reply and as far as I can tell, my original posting
> still hasn''t arrived on the list. I guess we''re still
having very
> sporadic list behaviour at the moment? Actually, my original posting
> is on Gmane, just never got mailed to me (but my other postings to the
> list usually do, unless we''re having list troubles).
What''s up with
> this list at the moment? :-S
>
> ~Dave
>
> --
>
> Dave Silvester
> Rent-A-Monkey Website Development
> Web: http://www.rentamonkey.com/
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails