private static MakeTime ( RubyContext context, object obj ) : RubyTime | ||
context | RubyContext | |
obj | object | |
return | RubyTime |
private static RubyTime MakeTime(RubyContext/*!*/ context, object obj) {
if (obj == null) {
return new RubyTime(DateTime.Now);
} else if (obj is RubyTime) {
return (RubyTime)obj;
} else if (obj is int) {
return new RubyTime(RubyTime.Epoch.AddSeconds((int)obj));
} else if (obj is double) {
return new RubyTime(RubyTime.Epoch.AddSeconds((double)obj));
} else {
string name = context.GetClassOf(obj).Name;
throw RubyExceptions.CreateTypeConversionError(name, "time");
}
}