public override bool Eql(object o) { if (o is RTime == false) { return(false); } RTime t = (RTime)o; return(time == t.time); }
static internal object minus(RBasic r, params object[] args) { NetRuby rb = r.ruby; if (args[0] is RTime) { double d = ((RTime)args[0]).ToDouble(); return(new RFloat(rb, (((RTime)r).ToDouble() - d) / 10000000)); } long l = ((RTime)r).ToLong() - RInteger.ToLong(rb, args[0]); RTime result = new RTime(rb, l * 10000000 + RTimeClass.Epoch); return(result.CopyFormat((RTime)r)); }
static internal object plus(RBasic r, params object[] args) { NetRuby rb = r.ruby; if (args[0] is RTime) { throw new eTypeError("time + time?"); } long l = RInteger.ToLong(rb, args[0]); l += ((RTime)r).ToLong(); RTime result = new RTime(rb, l * 10000000 + RTimeClass.Epoch); return(result.CopyFormat((RTime)r)); }
static internal object s_at(RBasic r, params object[] args) { NetRuby rb = r.ruby; object[] argv = new object[2]; long tmv = 0; long usec = 0; RTime result = null; int cnt = rb.ScanArgs(args, "11", argv); if (argv[0] is RTime) { DateTime tm = ((RTime)argv[0]).ToDateTime(); if (cnt == 2) { usec = RInteger.ToLong(rb, argv[1]); usec *= 10; result = new RTime(rb, tm.ToFileTime() + usec); } else { result = new RTime(rb, tm); } result.CopyFormat((RTime)argv[0]); } else { if (cnt == 2) { tmv = RInteger.ToLong(rb, argv[0]); usec = RInteger.ToLong(rb, argv[1]); usec *= 10; } else { tmv = RInteger.ToLong(rb, argv[0]); } // Adjust Unix Epoch to .NET tmv *= 1000; // mill second tmv *= 10000; // 100-nanosecond tmv += epoch; tmv += usec; result = new RTime(rb, tmv); } return(result); }
static internal object minus(RBasic r, params object[] args) { NetRuby rb = r.ruby; if (args[0] is RTime) { double d = ((RTime)args[0]).ToDouble(); return new RFloat(rb, (((RTime)r).ToDouble() - d) / 10000000); } long l = ((RTime)r).ToLong() - RInteger.ToLong(rb, args[0]); RTime result = new RTime(rb, l * 10000000 + RTimeClass.Epoch); return result.CopyFormat((RTime)r); }
static internal object plus(RBasic r, params object[] args) { NetRuby rb = r.ruby; if (args[0] is RTime) { throw new eTypeError("time + time?"); } long l = RInteger.ToLong(rb, args[0]); l += ((RTime)r).ToLong(); RTime result = new RTime(rb, l * 10000000 + RTimeClass.Epoch); return result.CopyFormat((RTime)r); }
static internal object s_at(RBasic r, params object[] args) { NetRuby rb = r.ruby; object[] argv = new object[2]; long tmv = 0; long usec = 0; RTime result = null; int cnt = rb.ScanArgs(args, "11", argv); if (argv[0] is RTime) { DateTime tm = ((RTime)argv[0]).ToDateTime(); if (cnt == 2) { usec = RInteger.ToLong(rb, argv[1]); usec *= 10; result = new RTime(rb, tm.ToFileTime() + usec); } else { result = new RTime(rb, tm); } result.CopyFormat((RTime)argv[0]); } else { if (cnt == 2) { tmv = RInteger.ToLong(rb, argv[0]); usec = RInteger.ToLong(rb, argv[1]); usec *= 10; } else { tmv = RInteger.ToLong(rb, argv[0]); } // Adjust Unix Epoch to .NET tmv *= 1000; // mill second tmv *= 10000; // 100-nanosecond tmv += epoch; tmv += usec; result = new RTime(rb, tmv); } return result; }
internal RTime CopyFormat(RTime t) { utc = t.utc; return this; }
internal RTime CopyFormat(RTime t) { utc = t.utc; return(this); }