Forum: JRuby Time bug? oddity? or user error?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
76aed56df3e087c55e6961f9fca7a6aa?d=identicon&s=25 Michael Campbell (Guest)
on 2009-05-30 21:51
(Received via mailing list)
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
Ede2aa10c6462f1d825143879be59e38?d=identicon&s=25 Charles Oliver Nutter (Guest)
on 2009-05-31 01:21
(Received via mailing list)
I'd call it a bug if it doesn't match MRI, so file it :)

Michael Campbell 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
76aed56df3e087c55e6961f9fca7a6aa?d=identicon&s=25 Michael Campbell (Guest)
on 2009-05-31 01:41
(Received via mailing list)
Charles Oliver Nutter wrote:
> I'd call it a bug if it doesn't match MRI, so file it :)

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



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
805e5c28b02309ff2769b828d7f9b453?d=identicon&s=25 Chiaming Hsu (Guest)
on 2009-05-31 03:34
(Received via mailing list)
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 Hsu




----- Original Message ----
From: Michael Campbell <michael.campbell@unixgeek.com>
To: user@jruby.codehaus.org
Sent: Saturday, May 30, 2009 4:41:07 PM
Subject: Re: [jruby-user] Time bug? oddity? or user error?

Charles Oliver Nutter wrote:
> I'd call it a bug if it doesn't match MRI, so file it :)

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
76aed56df3e087c55e6961f9fca7a6aa?d=identicon&s=25 Michael Campbell (Guest)
on 2009-05-31 04:00
(Received via mailing list)
Chiaming Hsu 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
40e5e9fe36a1f85166493faac2c17499?d=identicon&s=25 Hirotsugu Asari (Guest)
on 2009-05-31 04:10
(Received via mailing list)
On May 30, 2009, at 8:59 PM, Michael Campbell 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(TM)
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
805e5c28b02309ff2769b828d7f9b453?d=identicon&s=25 Chiaming Hsu (Guest)
on 2009-05-31 05:40
(Received via mailing list)
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 Hsu




----- Original Message ----
From: Hirotsugu Asari <asari.ruby@gmail.com>
To: user@jruby.codehaus.org
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 Campbell 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(TM)
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
Ba2f834cba243e6d678c06626d544918?d=identicon&s=25 Vladimir Sizikov (Guest)
on 2009-05-31 10:22
(Received via mailing list)
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. :)

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 Campbell
<michael.campbell@unixgeek.com> 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
76aed56df3e087c55e6961f9fca7a6aa?d=identicon&s=25 Michael Campbell (Guest)
on 2009-05-31 15:56
(Received via mailing list)
Vladimir Sizikov 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. :)
>
> 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
This topic is locked and can not be replied to.