Time bug? oddity? or user error?

I’ve just transitioned to Ubuntu (9.04) from Vista, and am noticing an
oddity with jruby Time. It could very well be user error, but wanted to
run it by you.

14:04:08 ~>ruby -e ‘p Time.now’
Sat May 30 14:04:13 -0400 2009

14:04:13 ~>jruby -e ‘p Time.now’
Sat May 30 18:04:18 UTC 2009

I’m in the US Eastern time zone, so the following especially seems wrong
to me.

14:04:18 ~>jruby -e ‘p Time.now.getlocal.gmt?’
true

14:08:03 ~>jruby -e ‘p Time.now.getlocal’
Sat May 30 18:08:08 UTC 2009

14:09:49 ~>jruby -e ‘p Time.now.localtime’
Sat May 30 18:10:10 UTC 2009

Is this an actual bug, or misunderstanding on what Time.now and
Time.getlocal should be doing? The rdoc on Time.local seems to agree
with me, but I might be misreading it, too. =)

14:04:57 ~>ruby -v
ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]

14:06:06 ~>jruby -v
jruby 1.1.5 (ruby 1.8.6 patchlevel 114) (2008-12-14 rev 6586)
[i386-java]

(1.3.0RC2 exhibits the same behavior)

Michael


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

I’d call it a bug if it doesn’t match MRI, so file it :slight_smile:

Michael C. wrote:

14:09:49 ~>jruby -e ‘p Time.now.localtime’
ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Charles Oliver N. wrote:

I’d call it a bug if it doesn’t match MRI, so file it :slight_smile:

You betcha: http://jira.codehaus.org/browse/JRUBY-3724


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

You may want to check if you have the environment variable TZ set
correctly to your time zone of desired. A few of us had issues on
Fedora that Sun JVM uses a different time zone from System if TZ is not
set. The issue caused the command “date” in bash returns a different
time zone format from JVM (same behavior in any language using JVM, such
as Java / Groovy / JRuby, etc.) Once I set TZ correctly (for me, it is
TZ=America/Los_Angeles), the problem went away.

If it is an JVM issue, I don’t think JRuby can do much about it…

Cheers,
Chiaming H.

----- Original Message ----
From: Michael C. [email protected]
To: [email protected]
Sent: Saturday, May 30, 2009 4:41:07 PM
Subject: Re: [jruby-user] Time bug? oddity? or user error?

Charles Oliver N. wrote:

I’d call it a bug if it doesn’t match MRI, so file it :slight_smile:

You betcha: http://jira.codehaus.org/browse/JRUBY-3724


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Chiaming H. wrote:

You may want to check if you have the environment variable TZ set correctly to your time zone of desired. A few of us had issues on Fedora that Sun JVM uses a different time zone from System if TZ is not set. The issue caused the command “date” in bash returns a different time zone format from JVM (same behavior in any language using JVM, such as Java / Groovy / JRuby, etc.) Once I set TZ correctly (for me, it is TZ=America/Los_Angeles), the problem went away.

If it is an JVM issue, I don’t think JRuby can do much about it…

That certainly helps, and I will add that to my startup.

BASH 21:57:13 mcampbell:~> jruby -e ‘puts Time.now’
Sun May 31 01:57:25 UTC 2009
BASH 21:57:25 mcampbell:~> TZ=America/New_York !!
TZ=America/New_York jruby -e ‘puts Time.now’
Sat May 30 21:57:35 -0400 2009

Thanks, Chiaming!

Charlie, should I close the jira, or is this still an issue that jruby
doesn’t match MRI with the same environment?


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

On May 30, 2009, at 8:59 PM, Michael C. wrote:

If it is an JVM issue, I don’t think JRuby can do much about it…
Thanks, Chiaming!

Charlie, should I close the jira, or is this still an issue that
jruby doesn’t match MRI with the same environment?

It fails in the 1.9 mode.

$ jruby --1.9 -ve ‘p Time.now’; ruby19 -ve ‘p Time.now’
jruby 1.3.0RC2 (ruby 1.9.1p0) (2009-05-29 d3af330) (Java HotSpot™
Client VM 1.5.0_16) [i386-java]
Sat May 30 20:47:12 -0500 2009
ruby 1.9.2dev (2009-05-29 trunk 23606) [i386-darwin9.7.0]
2009-05-30 20:47:12 -0500


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

That looks like the same time, but the default output String format
seems to have changed for MRI 1.9. Is it a requirement that default
output format for time need to match between MRI / JRuby? For me, as
long as the underlying time / time zone is correct, I don’t really care
about the default output String format. If the output format matters,
we should use specific formatters anyway.

Cheers,
Chiaming H.

----- Original Message ----
From: Hirotsugu A. [email protected]
To: [email protected]
Sent: Saturday, May 30, 2009 7:09:35 PM
Subject: Re: [jruby-user] Time bug? oddity? or user error?

On May 30, 2009, at 8:59 PM, Michael C. wrote:

TZ=America/New_York jruby -e ‘puts Time.now’
Sat May 30 21:57:35 -0400 2009

Thanks, Chiaming!

Charlie, should I close the jira, or is this still an issue that jruby doesn’t match MRI with the same environment?

It fails in the 1.9 mode.

$ jruby --1.9 -ve ‘p Time.now’; ruby19 -ve ‘p Time.now’
jruby 1.3.0RC2 (ruby 1.9.1p0) (2009-05-29 d3af330) (Java HotSpot™
Client VM 1.5.0_16) [i386-java]
Sat May 30 20:47:12 -0500 2009
ruby 1.9.2dev (2009-05-29 trunk 23606) [i386-darwin9.7.0]
2009-05-30 20:47:12 -0500


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Hi Michael,

I’ve seen weird Time behavior on Ubuntu (especially for US short zone
names) in the past, and spent quite some time trying to figure it out.
At the end, it was Ubuntu bug. :slight_smile:

For more details, take a look at the comments for
http://jira.codehaus.org/browse/JRUBY-2541

Looks similar?

Thanks,
–Vladimr

On Sat, May 30, 2009 at 9:50 PM, Michael C.
[email protected] wrote:

14:09:49 ~>jruby -e ‘p Time.now.localtime’
ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Vladimir S. wrote:

Hi Michael,

I’ve seen weird Time behavior on Ubuntu (especially for US short zone
names) in the past, and spent quite some time trying to figure it out.
At the end, it was Ubuntu bug. :slight_smile:

For more details, take a look at the comments for
http://jira.codehaus.org/browse/JRUBY-2541

Looks similar?

I believe that issue and the one I reported are one in the same. I’ve
resovled
my issue as a “duplicate”.

Thanks, Vladimir!

Michael


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email