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.
Jirapong N. (Guest)
on 2009-04-25 00: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
Jimmy S. (Guest)
on 2009-05-04 05: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: removed_email_address@domain.invalid
[mailto:removed_email_address@domain.invalid] On Behalf Of
removed_email_address@domain.invalid
Sent: Friday, April 24, 2009 1:56 PM
To: removed_email_address@domain.invalid
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
Jirapong N. (Guest)
on 2009-05-04 06: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
Shri B. (Guest)
on 2009-05-04 11: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: removed_email_address@domain.invalid
[mailto:removed_email_address@domain.invalid] On Behalf Of
removed_email_address@domain.invalid
Sent: Sunday, May 03, 2009 7:12 PM
To: removed_email_address@domain.invalid
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 S. 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:
removed_email_address@domain.invalid<mailto:removed_email_address@domain.invalid>
[mailto:removed_email_address@domain.invalid] On Behalf Of
removed_email_address@domain.invalid<mailto:removed_email_address@domain.invalid>
Sent: Friday, April 24, 2009 1:56 PM
To: 
removed_email_address@domain.invalid<mailto:removed_email_address@domain.invalid>
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
Shri B. (Guest)
on 2009-05-04 11: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: removed_email_address@domain.invalid
[mailto:removed_email_address@domain.invalid] On Behalf Of Shri B.
Sent: Monday, May 04, 2009 12:15 AM
To: removed_email_address@domain.invalid
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: removed_email_address@domain.invalid
[mailto:removed_email_address@domain.invalid] On Behalf Of
removed_email_address@domain.invalid
Sent: Sunday, May 03, 2009 7:12 PM
To: removed_email_address@domain.invalid
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 S. 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:
removed_email_address@domain.invalid<mailto:removed_email_address@domain.invalid>
[mailto:removed_email_address@domain.invalid] On Behalf Of
removed_email_address@domain.invalid<mailto:removed_email_address@domain.invalid>
Sent: Friday, April 24, 2009 1:56 PM
To: 
removed_email_address@domain.invalid<mailto:removed_email_address@domain.invalid>
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
Jirapong N. (Guest)
on 2009-05-04 21: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
Jirapong N. (Guest)
on 2009-05-04 23: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 B. 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.