change default timezone

Discussion in 'Ruby' started by Remco van 't Veer, Nov 8, 2005.

  1. 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
    Remco van 't Veer, Nov 8, 2005
    #1
    1. Advertising

  2. Remco van 't Veer

    Ara.T.Howard Guest

    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
    ===============================================================================
    Ara.T.Howard, Nov 8, 2005
    #2
    1. Advertising

  3. On 11/8/05, Ara.T.Howard <> 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
    Remco van 't Veer, Nov 8, 2005
    #3
  4. 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
    David N. Springer, Nov 8, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Maitland

    scope of default TimeZone

    Maitland, Mar 2, 2005, in forum: Java
    Replies:
    2
    Views:
    455
    Angus
    Mar 3, 2005
  2. Werner Lehmann

    Default timezone changes out of nowhere?

    Werner Lehmann, Jun 30, 2005, in forum: Java
    Replies:
    6
    Views:
    10,538
    Werner Lehmann
    Jul 2, 2005
  3. asaf
    Replies:
    3
    Views:
    6,136
    =?ISO-8859-1?Q?Arne_Vajh=F8j?=
    Sep 11, 2006
  4. axrock
    Replies:
    8
    Views:
    939
    Roedy Green
    Mar 25, 2009
  5. Ami
    Replies:
    5
    Views:
    266
Loading...

Share This Page