Search code examples
c#.netscriptingironrubyembedded-language

Embedding IronRuby in C# and DateTime


When I embed IronRuby what is the proper way to get a reference to either Ruby's DateTime/Date classes or .NET's System.DateTime. I'm running into errors when I try

require 'date'

I get the error - no such file to load -- date

when I try require 'mscorlib.dll' I get the error - no such file to load -- mscorlib.dll

What is the right way to do either of these?

UPDATE: see comments to Jon Skeet


Solution

  • Time is a core type in ruby which maps to a System.DateTime.

    To get DateTime.Now you can do Time.new

    There are datetime extensions so you could do require 'time' or require 'datetime'

    mscorlib is implied and is always required so you don't need to explicitly require it. if you want to get to the CLR DateTime you can do

    System::DateTime.now or System::DateTime.Now