From: Michael N. <mne...@nt...> - 2003-05-30 10:13:27
|
Hi, What do you think? For me it seems natural to use the local timezone instead of GMT. If there are no problems with existing applications, I'll make the change and soon release a new version.=20 Regards, Michael ----- Forwarded message from Stefano Cobianchi <st...@to...> ----- From: Stefano Cobianchi <st...@to...> To: ne...@s-... Subject: Bug in Ruby::DBI? Date: 19 May 2003 17:38:07 +0200 Hi I'm a Ruby developer and I use Ruby::DBI extensively in my work, especially in conjunction with MySQL. I thin I've found a bug in the code that converts a DATETIME sql field in a DBI::Timestamp object: def as_timestamp(str) return nil if str.nil? or str.empty? ary =3D ParseDate.parsedate(str) time =3D ::Time.gm(*(ary[0,6])) by calling ::Time.gm, you get an UTC time (in MySQL, "datetime" fields have no information about the local timezone) the right thing to do, I guess, is to call ::Time.local --=20 Stefano Cobianchi - st...@to... Tomato Interactive - www.tomato.it ----- End forwarded message ----- |
From: Paul D. <pa...@sn...> - 2003-05-30 12:48:54
|
At 12:13 +0200 5/30/03, Michael Neumann wrote: >Hi, > >What do you think? >For me it seems natural to use the local timezone instead of GMT. Stefano's right that datetime values in MySQL have no timezone information. But the time returned is in the *server's* local timezone. > >If there are no problems with existing applications, I'll make the >change and soon release a new version. > >Regards, > > Michael > >----- Forwarded message from Stefano Cobianchi <st...@to...> ----- > >From: Stefano Cobianchi <st...@to...> >To: ne...@s-... >Subject: Bug in Ruby::DBI? >Date: 19 May 2003 17:38:07 +0200 > >Hi > >I'm a Ruby developer and I use Ruby::DBI extensively in my work, >especially in conjunction with MySQL. >I thin I've found a bug in the code that converts a DATETIME sql >field in a DBI::Timestamp object: > > def as_timestamp(str) > return nil if str.nil? or str.empty? > ary = ParseDate.parsedate(str) > time = ::Time.gm(*(ary[0,6])) > >by calling ::Time.gm, you get an UTC time (in MySQL, "datetime" >fields have no information about the local timezone) >the right thing to do, I guess, is to call ::Time.local > > >-- >Stefano Cobianchi - st...@to... >Tomato Interactive - www.tomato.it > > >----- End forwarded message ----- > > > >------------------------------------------------------- >This SF.net email is sponsored by: eBay >Get office equipment for less on eBay! >http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5 >_______________________________________________ >Ruby-dbi-devel mailing list >Rub...@li... >https://lists.sourceforge.net/lists/listinfo/ruby-dbi-devel |
From: Michael N. <mne...@nt...> - 2003-05-30 17:32:55
|
On Fri, May 30, 2003 at 07:21:19AM -0500, Paul DuBois wrote: > At 12:13 +0200 5/30/03, Michael Neumann wrote: > >Hi, > > > >What do you think? > >For me it seems natural to use the local timezone instead of GMT. > > Stefano's right that datetime values in MySQL have no timezone > information. > > But the time returned is in the *server's* local timezone. So, if we don't know the server's timezone, the best we could do is to assume GMT (this at least would be determinant). Of course this behaviour should be documented somewhere. Would you agree? Regards, Michael |
From: Paul D. <pa...@sn...> - 2003-05-30 18:52:41
|
At 19:24 +0200 5/30/03, Michael Neumann wrote: >On Fri, May 30, 2003 at 07:21:19AM -0500, Paul DuBois wrote: >> At 12:13 +0200 5/30/03, Michael Neumann wrote: >> >Hi, >> > >> >What do you think? >> >For me it seems natural to use the local timezone instead of GMT. >> >> Stefano's right that datetime values in MySQL have no timezone >> information. >> >> But the time returned is in the *server's* local timezone. > >So, if we don't know the server's timezone, the best we could do is to >assume GMT (this at least would be determinant). Of course this >behaviour should be documented somewhere. > >Would you agree? I agree, but I wasn't clear on why there was any problem with using Time.gm in the first place. How does that manifest itself as incorrect behavior? > > >Regards, > > Michael |
From: Michael N. <mne...@nt...> - 2003-05-30 21:20:53
|
On Fri, May 30, 2003 at 01:11:41PM -0500, Paul DuBois wrote: > At 19:24 +0200 5/30/03, Michael Neumann wrote: > >On Fri, May 30, 2003 at 07:21:19AM -0500, Paul DuBois wrote: > >> At 12:13 +0200 5/30/03, Michael Neumann wrote: > >> >Hi, > >> > > >> >What do you think? > >> >For me it seems natural to use the local timezone instead of GMT. > >> > >> Stefano's right that datetime values in MySQL have no timezone > >> information. > >> > >> But the time returned is in the *server's* local timezone. > > > >So, if we don't know the server's timezone, the best we could do is to > >assume GMT (this at least would be determinant). Of course this > >behaviour should be documented somewhere. > > > >Would you agree? > > I agree, but I wasn't clear on why there was any problem with using > Time.gm in the first place. How does that manifest itself as incorrect > behavior? Well, if you store a datetime value in the database which is not in GMT (the value), then retrieve the same value from the database, it will be a different one (unless you always store datetime values in GMT). But without knowing the timezone, I fear there's no way to prevent that. Regards, Michael |