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/937a8c4aea048dd20ddea8aa6e27b0055bf6907d

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

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: [email protected]
[mailto:[email protected]] On Behalf Of
[email protected]
Sent: Friday, April 24, 2009 1:56 PM
To: [email protected]
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 - 101229’s gists · GitHub

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

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

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

Thanks,
-Jirapong

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: [email protected]
[mailto:[email protected]] On Behalf Of
[email protected]
Sent: Sunday, May 03, 2009 7:12 PM
To: [email protected]
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?WorkItemId=1021

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:
[email protected]mailto:[email protected]
[mailto:[email protected]] On Behalf Of
[email protected]mailto:[email protected]
Sent: Friday, April 24, 2009 1:56 PM
To: [email protected]mailto:[email protected]
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 - 101229’s gists · GitHub

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

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

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

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: [email protected]
[mailto:[email protected]] On Behalf Of Shri B.
Sent: Monday, May 04, 2009 12:15 AM
To: [email protected]
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: [email protected]
[mailto:[email protected]] On Behalf Of
[email protected]
Sent: Sunday, May 03, 2009 7:12 PM
To: [email protected]
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?WorkItemId=1021

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:
[email protected]mailto:[email protected]
[mailto:[email protected]] On Behalf Of
[email protected]mailto:[email protected]
Sent: Friday, April 24, 2009 1:56 PM
To: [email protected]mailto:[email protected]
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 - 101229’s gists · GitHub

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

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

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 :-)]