public static void setYear(JSDate dt, int year) { int newyear = dt.Value.Year; newyear = (newyear - newyear % 100) + (year % 100); dt.Value = new DateTime(newyear, dt.Value.Month, dt.Value.Day, dt.Value.Hour, dt.Value.Minute, dt.Value.Second, dt.Value.Millisecond); }
public JSDate(ExecutionContext GLOBAL) { mDateTime = DateTime.UtcNow; JSDate mPrototype = (JSDate)jsexec.GlobalOrNull(GLOBAL, "DatePrototype"); SetItem(GLOBAL, "prototype", new JSSimpleProperty("prototype", mPrototype)); }
public static void setUTCFullYear(JSDate dt, int year) { DateTime utc = dt.Value.ToUniversalTime(); utc = new DateTime(year, utc.Month, utc.Day, utc.Hour, utc.Minute, utc.Second, utc.Millisecond); dt.Value = utc.ToLocalTime(); }
public static void setUTCSeconds(JSDate dt, int seconds) { DateTime utc = dt.Value.ToUniversalTime(); utc = new DateTime(utc.Year, utc.Month, utc.Day, utc.Hour, utc.Minute, seconds, utc.Millisecond); dt.Value = utc.ToLocalTime(); }
public static void setUTCDate(JSDate dt, int date) { DateTime utc = dt.Value.ToUniversalTime(); utc = new DateTime(utc.Year, utc.Month, date, utc.Hour, utc.Minute, utc.Second, utc.Millisecond); dt.Value = utc.ToLocalTime(); }
public static int getUTCMinutes(JSDate dt) { return dt.Value.ToUniversalTime().Minute; }
public static int getUTCFullYear(JSDate dt) { return dt.Value.ToUniversalTime().Year; }
public static int getUTCDate(JSDate dt) { return dt.Value.ToUniversalTime().Day; }
public static int getUTCMilliseconds(JSDate dt) { return(dt.Value.ToUniversalTime().Millisecond); }
public static string toUTCString(JSDate dt) { return dt.Value.ToUniversalTime().ToString(); }
public static string toDateString(JSDate dt) { return dt.Value.ToLongDateString(); }
public static void setDate(JSDate dt, int newdate) { dt.Value = new DateTime(dt.Value.Year, dt.Value.Month, newdate, dt.Value.Hour, dt.Value.Minute, dt.Value.Second, dt.Value.Millisecond); }
public static void setMonth(JSDate dt, int month) { dt.Value = new DateTime(dt.Value.Year, month, dt.Value.Day, dt.Value.Hour, dt.Value.Minute, dt.Value.Second, dt.Value.Millisecond); }
public static void setSeconds(JSDate dt, int seconds) { dt.Value = new DateTime(dt.Value.Year, dt.Value.Month, dt.Value.Day, dt.Value.Hour, dt.Value.Minute, seconds, dt.Value.Millisecond); }
public static void setTime(JSDate dt, long time) { dt.Value = new DateTime(time * 10000 + ((new DateTime(1970, 1, 1)).Ticks)); }
public static void setHours(JSDate dt, int newhour) { dt.Value = new DateTime(dt.Value.Year, dt.Value.Month, dt.Value.Day, newhour, dt.Value.Minute, dt.Value.Second, dt.Value.Millisecond); }
public static void setFullYear(JSDate dt, int newyear) { dt.Value = new DateTime(newyear, dt.Value.Month, dt.Value.Day, dt.Value.Hour, dt.Value.Minute, dt.Value.Second, dt.Value.Millisecond); }
public static int getUTCSeconds(JSDate dt) { return dt.Value.ToUniversalTime().Second; }
public static long parse(ExecutionContext GLOBAL, string date) { return(JSDate.getTime(new JSDate(GLOBAL, DateTime.Parse(date)))); }
public static void setUTCMilliseconds(JSDate dt, int milliseconds) { setMilliseconds(dt, milliseconds); }
public static int getUTCHours(JSDate dt) { return(dt.Value.ToUniversalTime().Hour); }
public static string toLocaleString(JSDate dt) { return dt.Value.ToString(); }
public static long getTime(JSDate dt) { return (dt.Value.Ticks - (new DateTime(1970, 1, 1)).Ticks) / 10000; }
public static int getDay(JSDate dt) { return (int)dt.Value.DayOfWeek; }
public static int getUTCMinutes(JSDate dt) { return(dt.Value.ToUniversalTime().Minute); }
public static int getSeconds(JSDate dt) { return dt.Value.Second; }
public static string toGMTString(JSDate dt) { return(toUTCString(dt)); }
public static int getTimezoneOffset(JSDate dt) { return (int)((dt.Value.ToFileTime() - dt.Value.ToFileTimeUtc()) / 60 * 1000 * 10000); }
public static string toLocaleString(JSDate dt) { return(dt.Value.ToString()); }
public static int getUTCDay(JSDate dt) { return (int)dt.Value.ToUniversalTime().DayOfWeek; }
public static string toDateString(JSDate dt) { return(dt.Value.ToLongDateString()); }
public static int getUTCHours(JSDate dt) { return dt.Value.ToUniversalTime().Hour; }
public static string toTimeString(JSDate dt) { return(dt.Value.ToShortTimeString()); }
public static int getUTCMonth(JSDate dt) { return dt.Value.ToUniversalTime().Month; }
public static string toUTCString(JSDate dt) { return(dt.Value.ToUniversalTime().ToString()); }
public static long UTC(ExecutionContext GLOBAL) { return(JSDate.getTime(new JSDate(GLOBAL))); }
public static int getDate(JSDate dt) { return(dt.Value.Day); }
public static int getDay(JSDate dt) { return((int)dt.Value.DayOfWeek); }
public static int getFullYear(JSDate dt) { return(dt.Value.Year); }
public static int getHours(JSDate dt) { return(dt.Value.Hour); }
public static int getMilliseconds(JSDate dt) { return(dt.Value.Millisecond); }
public static string toGMTString(JSDate dt) { return toUTCString(dt); }
public static int getMinutes(JSDate dt) { return(dt.Value.Minute); }
public static string toTimeString(JSDate dt) { return dt.Value.ToShortTimeString(); }
public jsexec() { GLOBAL.jobject = new JSObject(); GLOBAL.jobject = GLOBAL.thisOb = new JSObject(); StaticObjectFun = new ObjectFun(GLOBAL); GLOBAL.jobject.SetItem(GLOBAL, "StaticObjectFun", new JSSimpleProperty("StaticObjectFun", StaticObjectFun)); StaticStringFun = new StringFun(GLOBAL); GLOBAL.jobject.SetItem(GLOBAL, "StaticStringFun", new JSSimpleProperty("StaticStringFun", StaticStringFun)); StaticBooleanFun = new BooleanFun(GLOBAL); GLOBAL.jobject.SetItem(GLOBAL, "StaticBooleanFun", new JSSimpleProperty("StaticBooleanFun", StaticBooleanFun)); StaticArrayFun = new ArrayFun(GLOBAL); GLOBAL.jobject.SetItem(GLOBAL, "StaticArrayFun", new JSSimpleProperty("StaticArrayFun", StaticArrayFun)); StaticNumberFun = new NumberFun(GLOBAL); GLOBAL.jobject.SetItem(GLOBAL, "StaticNumberFun", new JSSimpleProperty("StaticNumberFun", StaticNumberFun)); StaticFunctionFun = new FunctionFun(GLOBAL); GLOBAL.jobject.SetItem(GLOBAL, "StaticFunctionFun", new JSSimpleProperty("StaticFunctionFun", StaticFunctionFun)); //StaticNumberObject = new NumberObject(GLOBAL, 0.0); #if !JS_SLIM DatePrototype = new JSDate(GLOBAL); GLOBAL.jobject.SetItem(GLOBAL, "DatePrototype", new JSSimpleProperty("DatePrototype", DatePrototype)); JSDate.SetupPrototype(GLOBAL, DatePrototype); #endif GLOBAL.jobject.SetItem(GLOBAL, "toString", new JSNativeMethod(typeof(JSObject), "StaticToString")); /* Core types */ JSObject thisOb = (JSObject)GLOBAL.thisOb; thisOb.DefProp(GLOBAL, "Object", StaticObjectFun); thisOb.DefProp(GLOBAL, "Function", StaticFunctionFun); thisOb.DefProp(GLOBAL, "Boolean", StaticBooleanFun); thisOb.DefProp(GLOBAL, "Number", StaticNumberFun); thisOb.DefProp(GLOBAL, "String", StaticStringFun); thisOb.DefProp(GLOBAL, "Array", StaticArrayFun); /* Types that work like classes */ #if !JS_SLIM thisOb.DefProp(GLOBAL, "Math", JSClassWrapper.RegisterClass(GLOBAL, typeof(pygmalion.JSMath))); thisOb.DefProp(GLOBAL, "Date", JSClassWrapper.RegisterClass(GLOBAL, typeof(pygmalion.JSDate))); thisOb.DefProp(GLOBAL, "Error", JSClassWrapper.RegisterClass(GLOBAL, typeof(pygmalion.JSError))); /* Standard library */ thisOb.DefProp(GLOBAL, "decodeURI", new DecodeURIFun()); thisOb.DefProp(GLOBAL, "decodeURIComponent", new DecodeURIComponentFun()); thisOb.DefProp(GLOBAL, "encodeURI", new EncodeURIFun()); thisOb.DefProp(GLOBAL, "encodeURIComponent", new EncodeURIComponentFun()); thisOb.DefProp(GLOBAL, "escape", new EscapeFun()); #endif thisOb.DefProp(GLOBAL, "eval", new EvalFun()); thisOb.DefProp(GLOBAL, "gc", new GcFun()); thisOb.DefProp(GLOBAL, "Infinity", double.PositiveInfinity, false, false, false); thisOb.DefProp(GLOBAL, "isFinite", new isFiniteFun()); thisOb.SetItem(GLOBAL, "isNaN", new JSNativeMethod(typeof(Double), "IsNaN")); thisOb.DefProp(GLOBAL, "parseFloat", new ParseFloat(), false, false, false); thisOb.DefProp(GLOBAL, "parseInt", new ParseInt(), false, false, false); thisOb.DefProp(GLOBAL, "NaN", double.NaN, false, false, false); thisOb.DefProp(GLOBAL, "unescape", new UnescapeFun()); thisOb.DefProp(GLOBAL, "version", new VersionFun()); GLOBAL.jobject.SetItem(GLOBAL, "JSExec", new JSSimpleProperty("JSExec", this)); GLOBAL.thisOb = GLOBAL.jobject; GLOBAL.currentContext = new ExecutionContext(GLOBAL); GLOBAL.scope = GLOBAL.currentContext; }
public static int getDate(JSDate dt) { return dt.Value.Day; }
public static int getMonth(JSDate dt) { return dt.Value.Month; }
public static int getFullYear(JSDate dt) { return dt.Value.Year; }
public static int getUTCFullYear(JSDate dt) { return(dt.Value.ToUniversalTime().Year); }