Date Class and GMT

Z

Zach Dennis

I:\>irb
irb(main):001:0> Time.now
=> Wed Nov 26 11:29:24 Eastern Standard Time 2003
irb(main):002:0> Time.now.gmtime
=> Wed Nov 26 16:29:29 UTC 2003
irb(main):003:0>



I need to be able to return the zone by it's numeric representation(
i.e. -0500 ). Like

Wed Nov 26 16:29:29 UTC 2003 -0500

by chance.

I cannot find a function to do this. Is it built in or can i request an
addition?

Thanks,

Zach
 
T

Tadayoshi Funaba

At 2003-11-27T01:42:12+0900
However, as I have posted here before, there is a bug in this
library which for some reason automatically increases the time zone
offset from UTC by one minute, so if you run the above examples on your
system you will probably see -0501 instead of -0500. This problem is
easily fixed by removing the line

I've just read your mail. I don't read nearly all discussions in
English now.

I think you are right. I intended to consider leap seconds. But, I
was in confusion.

Thank you for your report.

--tadf


--- date.rb 2003-08-12 05:09:41+09 2.9
+++ date.rb 2004-01-17 16:51:52+09
@@ -1,4 +1,4 @@
-# date.rb: Written by Tadayoshi Funaba 1998-2003
+# date.rb: Written by Tadayoshi Funaba 1998-2004
# $Id: date.rb,v 2.9 2003-08-12 05:09:41+09 tadf Exp tadf $

require 'rational'
@@ -508,8 +508,7 @@
jd = civil_to_jd(*(a[0,3] << sg))
fr = time_to_day_fraction(*(a[3,3])) + i.usec.to_r/86400000000
d = Time.gm(*i.to_a).to_i - i.to_i
- d += d / d.abs if d.nonzero?
- of = (d / 60).to_r/1440
+ of = (d / 60.0).round.to_r/1440
new0(jd_to_ajd(jd, fr, of), of, sg)
end
 

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

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,197
Latest member
ScottChare

Latest Threads

Top