--- Rie! <[EMAIL PROTECTED]> wrote:
> On 27/03/2008, Edwin Pratomo <[EMAIL PROTECTED]> wrote:
>
> I knew that command won't change my timezone, however I'm not sure
> that command might help, cos that is how to *set* the current time,
> not to *get* the current time. Can you do that command *inside irb* to
> *get* a local variable as a PST ?
>
> irb
> >> a = Time.now
> >> IO.popen("env something #{a}") <------------- this is too ugly if
> this what you meant
env is available as ENV hash.
class Time
def self.pst
begin
old_tz = ENV['TZ']
ENV['TZ'] = "US/Pacific"
t = Time.now
t.to_s # force localtime(3) call using this TZ
t
ensure
ENV['TZ'] = old_tz
end
end
end
p Time.pst # Fri Mar 28 01:47:32 -0700 2008
p Time.now # Fri Mar 28 15:47:32 +0700 2008
rgds,
Edwin.
________________________________________________________
Kunjungi halaman depan Yahoo! Indonesia yang baru!
http://id.yahoo.com/