Example #1
0
        public override bool Eql(object o)
        {
            if (o is RTime == false)
            {
                return(false);
            }
            RTime t = (RTime)o;

            return(time == t.time);
        }
Example #2
0
        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));
        }
Example #3
0
        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));
        }
Example #4
0
        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);
        }
Example #5
0
        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);
        }
Example #6
0
 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);
 }
Example #7
0
 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;
 }
Example #8
0
 internal RTime CopyFormat(RTime t)
 {
     utc = t.utc;
     return this;
 }
Example #9
0
 internal RTime CopyFormat(RTime t)
 {
     utc = t.utc;
     return(this);
 }