change default timezone

  • Thread starter Remco van 't Veer
  • Start date
R

Remco van 't Veer

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
 
A

Ara.T.Howard

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
===============================================================================
 
R

Remco van 't Veer

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
 
D

David N. Springer

Remco said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top