Change default timezone

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

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

···

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.

--

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

===============================================================================

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

That's too obvious! :wink: Thanks.

Remco

···

On 11/8/05, Ara.T.Howard <Ara.T.Howard@noaa.gov> 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 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