Forum: IronRuby Time class instance

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.
806ef55917f436850d2c4b0a5703e7cc?d=identicon&s=25 Jirapong Nanta (jirapong)
on 2009-04-24 22:56
(Received via mailing list)
Hi
  Time class instance in IronRuby act as static. Given following code:

t = Time.new
t.utc
t.utc? # should be true behave

t.localtime
t.utc? # should be false

"t" should convert itself into UTC type after method "utc" being
called. There are three methods must modifying the receiver; utc,
gmtime, and localtime

It also effect to Time.rfc2882 formating  as you can run MRI vs
IronRuby at - http://gist.github.com/101229

I have propose my fix at -
http://github.com/Jirapong/ironruby/commit/937a8c4...

File changes:
  • Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/ironruby-
tags/library/time/rfc2822_tags.txt
  • Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/
core/time/utc_spec.rb
  • Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/
FileOps.cs
  • Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/
TimeOps.cs
  • Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/
Initializers.Generated.cs
  • Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Zlib/zlib.cs
  • Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyDateTime.cs
  • Merlin/Main/Languages/Ruby/Ruby/Ruby.csproj

Note: Shri, this push should fix
23) Failure:
test_request_unmodifed(TestGemRemoteFetcher)
[test_gem_remote_fetcher.rb:604]:
Expected "Mon, 13 Apr 2009 13:22:16 -0700", not "Mon, 13 Apr 2009
20:22:16 -0000"

Thank you,
-Jirapong
E1deaac6561498a0e7472e6268ea9ccc?d=identicon&s=25 Jimmy Schementi (Guest)
on 2009-05-04 03:44
(Received via mailing list)
Doesn't look like anyone has reviewed this yet. To make sure it doesn't
get lost, can you also make a bug on codeplex for this?

From: ironruby-core-bounces@rubyforge.org
[mailto:ironruby-core-bounces@rubyforge.org] On Behalf Of
jirapong.nanta@gmail.com
Sent: Friday, April 24, 2009 1:56 PM
To: ironruby-core@rubyforge.org
Subject: [Ironruby-core] Time class instance

Hi
          Time class instance in IronRuby act as static. Given following
code:

t = Time.new
t.utc
t.utc? # should be true behave

t.localtime
t.utc? # should be false

"t" should convert itself into UTC type after method "utc" being called.
There are three methods must modifying the receiver; utc, gmtime, and
localtime

It also effect to Time.rfc2882 formating  as you can run MRI vs IronRuby
at - http://gist.github.com/101229

I have propose my fix at -
http://github.com/Jirapong/ironruby/commit/937a8c4...

File changes:
          *
Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/ironruby-tags/library/time/rfc2822_tags.txt
          *
Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/core/time/utc_spec.rb
          *
Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/FileOps.cs
          *
Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/TimeOps.cs
          *
Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Initializers.Generated.cs
          *
Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Zlib/zlib.cs
          * Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyDateTime.cs
          * Merlin/Main/Languages/Ruby/Ruby/Ruby.csproj

Note: Shri, this push should fix
23) Failure:

test_request_unmodifed(TestGemRemoteFetcher)
[test_gem_remote_fetcher.rb:604]:

Expected "Mon, 13 Apr 2009 13:22:16 -0700", not "Mon, 13 Apr 2009
20:22:16 -0000"

Thank you,
-Jirapong
806ef55917f436850d2c4b0a5703e7cc?d=identicon&s=25 Jirapong Nanta (jirapong)
on 2009-05-04 04:12
(Received via mailing list)
Hi,
  It would be nice to have anyone to review my code :-). bug file in
at  http://ironruby.codeplex.com/WorkItem/View.aspx?Wo...

Thanks,
-Jirapong
Aea6cfe04952626ab630bde47ff82f89?d=identicon&s=25 Shri Borde (Guest)
on 2009-05-04 09:17
(Received via mailing list)
The approach looks good. I have some comments though...

You should do a search for "DateTime" in the code base to find all the
places that might need updating. For example, Yaml.DateTimeOps needs to
be changed (is there no spec for it?), and Converter.IsIntegral might
need to be.

RubyDateTime should be a good .NET citizen. You should override Equals
(and HashCode) - I suspect comparison might be broken without that since
DateTime was a valuetype whereas RubyDateTime is not. Also ToString. You
should define implicit operator converting from and to DateTime so that
Ruby code can pass a Ruby Time object to a CLR method that expects
DateTime. Would be nice to add constructors to RubyDateTime to match the
contructors of DateTime so that you can directly create instances of
RubyDateTime using "new RubyDateTime(args)" instead of using nested
expressions like "new RubyDateTime(new DateTime(args))" which is harder
to read. You should mark it as Serializable. Take a look at DateTime on
msdn.com and see if there are any other interfaces or attributes you can
propagate from DateTime to RubyDateTime.

The comment for RubyDateTime confused me a bit. Instead of "RubyDateTime
to encapsulates DateTime type which support instance's variable", should
it not be "Encapsulates DateTime and supports mutating of instances
(whereas DateTime is immutable)"

Creating bugs for code reviews is extra process for you. We can try to
avoid it until there are too many code reviews. So do send a reminder if
no one replies to your changes within 48 hours.

From: ironruby-core-bounces@rubyforge.org
[mailto:ironruby-core-bounces@rubyforge.org] On Behalf Of
jirapong.nanta@gmail.com
Sent: Sunday, May 03, 2009 7:12 PM
To: ironruby-core@rubyforge.org
Subject: Re: [Ironruby-core] Time class instance

Hi,
            It would be nice to have anyone to review my code :-). bug
file in at
http://ironruby.codeplex.com/WorkItem/View.aspx?Wo...

Thanks,
-Jirapong

On May 4, 2009, at 8:43 AM, Jimmy Schementi wrote:


Doesn't look like anyone has reviewed this yet. To make sure it doesn't
get lost, can you also make a bug on codeplex for this?

From:
ironruby-core-bounces@rubyforge.org<mailto:ironruby-core-bounces@rubyforge.org>
[mailto:ironruby-core-bounces@rubyforge.org] On Behalf Of
jirapong.nanta@gmail.com<mailto:jirapong.nanta@gmail.com>
Sent: Friday, April 24, 2009 1:56 PM
To: ironruby-core@rubyforge.org<mailto:ironruby-core@rubyforge.org>
Subject: [Ironruby-core] Time class instance

Hi
          Time class instance in IronRuby act as static. Given following
code:

t = Time.new
t.utc
t.utc? # should be true behave

t.localtime
t.utc? # should be false

"t" should convert itself into UTC type after method "utc" being called.
There are three methods must modifying the receiver; utc, gmtime, and
localtime

It also effect to Time.rfc2882 formating  as you can run MRI vs IronRuby
at - http://gist.github.com/101229

I have propose my fix at -
http://github.com/Jirapong/ironruby/commit/937a8c4...

File changes:
          *
Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/ironruby-tags/library/time/rfc2822_tags.txt
          *
Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/core/time/utc_spec.rb
          *
Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/FileOps.cs
          *
Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/TimeOps.cs
          *
Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Initializers.Generated.cs
          *
Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Zlib/zlib.cs
          * Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyDateTime.cs
          * Merlin/Main/Languages/Ruby/Ruby/Ruby.csproj

Note: Shri, this push should fix
23) Failure:

test_request_unmodifed(TestGemRemoteFetcher)
[test_gem_remote_fetcher.rb:604]:

Expected "Mon, 13 Apr 2009 13:22:16 -0700", not "Mon, 13 Apr 2009
20:22:16 -0000"

Thank you,
-Jirapong
Aea6cfe04952626ab630bde47ff82f89?d=identicon&s=25 Shri Borde (Guest)
on 2009-05-04 09:26
(Received via mailing list)
Why did you need to disable two examples in rfc2822_spec.rb? We should
not be disabling tests that worked before without a very good reason.

You added a test for Time.utc. That should actually be in the second
describe block in the same file for Time#utc. The (grammatically
correct) name of the examples should be "modifies the receiver"

From: ironruby-core-bounces@rubyforge.org
[mailto:ironruby-core-bounces@rubyforge.org] On Behalf Of Shri Borde
Sent: Monday, May 04, 2009 12:15 AM
To: ironruby-core@rubyforge.org
Subject: Re: [Ironruby-core] Time class instance

The approach looks good. I have some comments though...

You should do a search for "DateTime" in the code base to find all the
places that might need updating. For example, Yaml.DateTimeOps needs to
be changed (is there no spec for it?), and Converter.IsIntegral might
need to be.

RubyDateTime should be a good .NET citizen. You should override Equals
(and HashCode) - I suspect comparison might be broken without that since
DateTime was a valuetype whereas RubyDateTime is not. Also ToString. You
should define implicit operator converting from and to DateTime so that
Ruby code can pass a Ruby Time object to a CLR method that expects
DateTime. Would be nice to add constructors to RubyDateTime to match the
contructors of DateTime so that you can directly create instances of
RubyDateTime using "new RubyDateTime(args)" instead of using nested
expressions like "new RubyDateTime(new DateTime(args))" which is harder
to read. You should mark it as Serializable. Take a look at DateTime on
msdn.com and see if there are any other interfaces or attributes you can
propagate from DateTime to RubyDateTime.

The comment for RubyDateTime confused me a bit. Instead of "RubyDateTime
to encapsulates DateTime type which support instance's variable", should
it not be "Encapsulates DateTime and supports mutating of instances
(whereas DateTime is immutable)"

Creating bugs for code reviews is extra process for you. We can try to
avoid it until there are too many code reviews. So do send a reminder if
no one replies to your changes within 48 hours.

From: ironruby-core-bounces@rubyforge.org
[mailto:ironruby-core-bounces@rubyforge.org] On Behalf Of
jirapong.nanta@gmail.com
Sent: Sunday, May 03, 2009 7:12 PM
To: ironruby-core@rubyforge.org
Subject: Re: [Ironruby-core] Time class instance

Hi,
            It would be nice to have anyone to review my code :-). bug
file in at
http://ironruby.codeplex.com/WorkItem/View.aspx?Wo...

Thanks,
-Jirapong

On May 4, 2009, at 8:43 AM, Jimmy Schementi wrote:

Doesn't look like anyone has reviewed this yet. To make sure it doesn't
get lost, can you also make a bug on codeplex for this?

From:
ironruby-core-bounces@rubyforge.org<mailto:ironruby-core-bounces@rubyforge.org>
[mailto:ironruby-core-bounces@rubyforge.org] On Behalf Of
jirapong.nanta@gmail.com<mailto:jirapong.nanta@gmail.com>
Sent: Friday, April 24, 2009 1:56 PM
To: ironruby-core@rubyforge.org<mailto:ironruby-core@rubyforge.org>
Subject: [Ironruby-core] Time class instance

Hi
          Time class instance in IronRuby act as static. Given following
code:

t = Time.new
t.utc
t.utc? # should be true behave

t.localtime
t.utc? # should be false

"t" should convert itself into UTC type after method "utc" being called.
There are three methods must modifying the receiver; utc, gmtime, and
localtime

It also effect to Time.rfc2882 formating  as you can run MRI vs IronRuby
at - http://gist.github.com/101229

I have propose my fix at -
http://github.com/Jirapong/ironruby/commit/937a8c4...

File changes:
          *
Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/ironruby-tags/library/time/rfc2822_tags.txt
          *
Merlin/External.LCA_RESTRICTED/Languages/IronRuby/mspec/rubyspec/core/time/utc_spec.rb
          *
Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/FileOps.cs
          *
Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Builtins/TimeOps.cs
          *
Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Initializers.Generated.cs
          *
Merlin/Main/Languages/Ruby/Libraries.LCA_RESTRICTED/Zlib/zlib.cs
          * Merlin/Main/Languages/Ruby/Ruby/Builtins/RubyDateTime.cs
          * Merlin/Main/Languages/Ruby/Ruby/Ruby.csproj

Note: Shri, this push should fix
23) Failure:

test_request_unmodifed(TestGemRemoteFetcher)
[test_gem_remote_fetcher.rb:604]:

Expected "Mon, 13 Apr 2009 13:22:16 -0700", not "Mon, 13 Apr 2009
20:22:16 -0000"

Thank you,
-Jirapong
806ef55917f436850d2c4b0a5703e7cc?d=identicon&s=25 Jirapong Nanta (jirapong)
on 2009-05-04 19:28
(Received via mailing list)
Hello Shri,
  Thank you very much for code review. It is make sense about
constructors and ToString methods. I will work on it.

p.s. please delete bug #1021 for me.

Thank you,
-Jirapong
806ef55917f436850d2c4b0a5703e7cc?d=identicon&s=25 Jirapong Nanta (jirapong)
on 2009-05-04 21:03
(Received via mailing list)
Hello Shri,
  Because the spec passed by accident, I was checked result by this
code snippet

require 'time'

t1 = (Time.utc(1976, 8, 26, 14, 30) + 4 * 3600)
t2 = Time.rfc2822("26 Aug 76 14:30 EDT")

puts "#{t1} == #{t2}? #{t1==t2}"

MRI:
Thu Aug 26 18:30:00 UTC 1976 == Fri Aug 27 01:30:00 +0700 1976 true

IrunRuby:
Thu Aug 26 18:30:00 Z 1976 == Thu Aug 26 18:30:00 Z 1976? true

According to rfc2822 section - 3.3. Date and Time Specification
(http://www.ietf.org/rfc/rfc2822.txt
) Timezone of rfc2822 should display in (( "+" / "-" ) 4DIGIT format.

Thank you,
-Jirapong


On May 4, 2009, at 2:25 PM, Shri Borde wrote:

> Why did you need to disable two examples in rfc2822_spec.rb? We
> should not be disabling tests that worked before without a very good
> reason.
>
> You added a test for Time.utc. That should actually be in the second
> describe block in the same file for Time#utc. The (grammatically
> correct) name of the examples should be “modifies the receiver”
[Thanks for correction :-)]
This topic is locked and can not be replied to.