# Code Review: Time7

**URL:** <https://www.ruby-forum.com/t/code-review-time7/179600>\
**Category:** IronRuby\
**Created:** [November 30, 2009, 5:37am UTC](https://www.ruby-forum.com/t/code-review-time7/179600 "2009-11-30T05:37:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![grujildo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/94ad74/32.png) [@grujildo](https://www.ruby-forum.com/u/grujildo)\
**Post date:** [November 30, 2009, 5:37am UTC](https://www.ruby-forum.com/t/code-review-time7/179600/1 "2009-11-30T05:37:55Z")

</div>

tfpt review “/shelveset:Time7;REDMOND\tomat”  
Comment :

Adds NoUnderlyingType to ModuleRestrictions.

- If set, the members of the underlying CLR type are not accessible  
from Ruby (not even via clr\_new, etc.)
- A Ruby library class/module can either extend an existing CLR type  
or be self-contained. A self-contained class/module has  
ModuleRestriction.NoUnderlyingType set by default.

Separates Ruby method implementations on RubyTime to a separate class  
so that we can expose RubyTime underlying CLR type.

Fixes bugs and Time related specs:  
[http://ironruby.codeplex.com/WorkItem/View.aspx?WorkItemId=2912](http://ironruby.codeplex.com/WorkItem/View.aspx?WorkItemId=2912)  
[http://ironruby.codeplex.com/WorkItem/View.aspx?WorkItemId=2217](http://ironruby.codeplex.com/WorkItem/View.aspx?WorkItemId=2217)

Time zones  
It seems that MRI is using CRT zone API (\_tzset) on Windows. That API  
([http://msdn.microsoft.com/en-us/library/90s5c885(VS.80).aspx](http://msdn.microsoft.com/en-us/library/90s5c885(VS.80).aspx)) is buggy  
and also different from Unix API based on TZ environment variable. The  
only thing \_tzset does is that it parses TZ environment variable value  
using format \< zone offset hh:mm:ss\> and stores the  
parsed values into global variables. It doesn’t look up time zone name  
in any database (registry) or even allow to specify DST offset and rule  
(unlike POSIX TZ variable). As a consequence MRI on Windows doesn’t  
correctly implement daylight saving related API (Time#dst?). If the  
offset is not specified in TZ variable we don’t know anything about the  
zone and thus no zone related methods work correctly. And indeed the  
specs are failing. Besides, MRI doesn’t update the current time zone if  
TZ environment variable is changed at runtime (it only parses it once  
when the process is initialized) -  
[http://redmine.ruby-lang.org/issues/show/1972](http://redmine.ruby-lang.org/issues/show/1972).

This change makes IronRuby recognize TZ environment variable and  
update the current time zone whenever ENV[“TZ”] is assigned to. Current  
limitations:

1. TZ variable needs to define zone offset. We don’t do time zone  
name lookup and so only time zone name or abbreviation is not  
sufficient. If the offset is not specified we use the default time zone  
provided by OS and report a warning.
2. Time#dst? always uses the default OS zone, not the one that is  
specified by TZ variable. A warning is reported if the current zone  
comes from TZ variable.

Fixes Time specs that were relying on Unix specific commands.

Fixes time related bugs in YAML and a bug in the YAML scanner:  
[http://ironruby.codeplex.com/WorkItem/View.aspx?WorkItemId=2044](http://ironruby.codeplex.com/WorkItem/View.aspx?WorkItemId=2044)

Enables subclassing socket classes, fixes:  
[http://ironruby.codeplex.com/WorkItem/View.aspx?WorkItemId=3196](http://ironruby.codeplex.com/WorkItem/View.aspx?WorkItemId=3196)

There is a also bug in tzinfo gem:  
C:\M0\Merlin\External.LCA\_RESTRICTED\Languages\Ruby\ruby-1.8.6p368\lib\ruby\gems\1.8\gems\tzinfo-0.3.15\lib\tzinfo\time\_or\_datetime.rb  
Line #43 is missing usec parameter:  
@time = Time.utc(@time.year, @time.mon, @time.mday, @time.hour,  
@time.min, @time.sec, @time.usec) unless @time.zone == ‘UTC’

Tomas
