Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > change default timezone

Reply
Thread Tools

change default timezone

 
 
Remco van 't Veer
Guest
Posts: n/a
 
      11-08-2005
Hi,

My name is Remco, I am new to this list and still feeling my way
around ruby. If this issue has already been handled on this list I
apologize.

I am running a ruby web-application on a server in a different
timezone and I would like to force it into thinking it's in my
timezone (and do the proper adjustments). I thought about reopening
the Time class and redefine some member but can't figure out which to
change. Maybe there's some other way? The application is hosted on
debian linux.

TIA,
Remco


 
Reply With Quote
 
 
 
 
Ara.T.Howard
Guest
Posts: n/a
 
      11-08-2005
On Tue, 8 Nov 2005, Remco van 't Veer wrote:

> Hi,
>
> My name is Remco, I am new to this list and still feeling my way around
> ruby. If this issue has already been handled on this list I apologize.
>
> I am running a ruby web-application on a server in a different timezone and
> I would like to force it into thinking it's in my timezone (and do the
> proper adjustments). I thought about reopening the Time class and redefine
> some member but can't figure out which to change. Maybe there's some other
> way? The application is hosted on debian linux.


this might get you going:

harp:~ > cat a.rb
t = Time::now
p t

ENV["TZ"] = "PST+8"
t = Time::now
p t

harp:~ > ruby a.rb
Tue Nov 08 07:26:05 MST 2005
Tue Nov 08 06:26:05 PST 2005

hth.

-a
--
================================================== =============================
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| anything that contradicts experience and logic should be abandoned.
| -- h.h. the 14th dalai lama
================================================== =============================



 
Reply With Quote
 
 
 
 
Remco van 't Veer
Guest
Posts: n/a
 
      11-08-2005
On 11/8/05, Ara.T.Howard <(E-Mail Removed)> wrote:
> On Tue, 8 Nov 2005, Remco van 't Veer wrote:
>
> > I am running a ruby web-application on a server in a different timezone=

and
> > I would like to force it into thinking it's in my timezone (and do the
> > proper adjustments). I thought about reopening the Time class and rede=

fine
> > some member but can't figure out which to change. Maybe there's some o=

ther
> > way? The application is hosted on debian linux.

>
> this might get you going:
>
> harp:~ > cat a.rb
> t =3D Time::now
> p t
>
> ENV["TZ"] =3D "PST+8"
> t =3D Time::now
> p t
>
> harp:~ > ruby a.rb
> Tue Nov 08 07:26:05 MST 2005
> Tue Nov 08 06:26:05 PST 2005


That's too obvious! Thanks.

Remco


 
Reply With Quote
 
David N. Springer
Guest
Posts: n/a
 
      11-08-2005
Remco van 't Veer wrote:

>Hi,
>
>My name is Remco, I am new to this list and still feeling my way
>around ruby. If this issue has already been handled on this list I
>apologize.
>
>I am running a ruby web-application on a server in a different
>timezone and I would like to force it into thinking it's in my
>timezone (and do the proper adjustments). I thought about reopening
>the Time class and redefine some member but can't figure out which to
>change. Maybe there's some other way? The application is hosted on
>debian linux.
>
>TIA,
>Remco
>
>

Here is an alternate way, in case you don't want to hardcode it in your
application.

env TZ='PST+8' ruby -e 'p Time::now'

Tue Nov 08 07:12:37 PST 2005

--
David




 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
TimeZone change - how to use TimeZone class axrock Java 8 03-25-2009 11:54 PM
TimeZone calculation on Windows Vista with DateTime::TimeZone Ami Perl Misc 5 09-24-2007 07:27 AM
Convert windows TimeZone to Java TimeZone asaf Java 3 09-11-2006 05:40 PM
Default timezone changes out of nowhere? Werner Lehmann Java 6 07-02-2005 12:28 AM
scope of default TimeZone Maitland Java 2 03-03-2005 02:16 AM



Advertisments