// Note: "TIME" is both a bound variable AND a built-in function now. // If it gets called with parentheses(), the script calls this built-in function. // If it gets called without them, then the bound variable is what gets called instead. // Calling it using parentheses but with empty args: TIME() gives the same result // as the bound variable. While it would be cleaner to make it JUST a built-in function, // the bound variable had to be retained for backward compatibility with scripts // that call TIME without parentheses. public override void Execute(SharedObjects shared) { double ut; // Accepts zero or one arg: int argCount = CountRemainingArgs(shared); // If zero args, then the default is to assume you want to // make a TimeStamp of "now": if (argCount == 0) { ReturnValue = new kOS.Suffixed.TimeStamp(Planetarium.GetUniversalTime()); } // If one arg, then assume its in UT timestamp seconds: else if (argCount == 1) { ut = GetDouble(PopValueAssert(shared)); ReturnValue = new kOS.Suffixed.TimeStamp(ut); } // If more args, assume they are year, day, hour, minute, second, with optional // args at the end (eg. if there's only 3 args, it's year, day, hour with no minutes or seconds). else if (argCount == 2) { double day = GetDouble(PopValueAssert(shared)); double year = GetDouble(PopValueAssert(shared)); ReturnValue = new kOS.Suffixed.TimeStamp(year, day, 0.0, 0.0, 0.0); } else if (argCount == 3) { double hour = GetDouble(PopValueAssert(shared)); double day = GetDouble(PopValueAssert(shared)); double year = GetDouble(PopValueAssert(shared)); ReturnValue = new kOS.Suffixed.TimeStamp(year, day, hour, 0.0, 0.0); } else if (argCount == 4) { double minute = GetDouble(PopValueAssert(shared)); double hour = GetDouble(PopValueAssert(shared)); double day = GetDouble(PopValueAssert(shared)); double year = GetDouble(PopValueAssert(shared)); ReturnValue = new kOS.Suffixed.TimeStamp(year, day, hour, minute, 0.0); } else if (argCount == 5) { double second = GetDouble(PopValueAssert(shared)); double minute = GetDouble(PopValueAssert(shared)); double hour = GetDouble(PopValueAssert(shared)); double day = GetDouble(PopValueAssert(shared)); double year = GetDouble(PopValueAssert(shared)); ReturnValue = new kOS.Suffixed.TimeStamp(year, day, hour, minute, second); } AssertArgBottomAndConsume(shared); }