Example #1
0
        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);
        }
Example #2
0
        public JSDate(ExecutionContext GLOBAL)
        {
            mDateTime = DateTime.UtcNow;
            JSDate mPrototype = (JSDate)jsexec.GlobalOrNull(GLOBAL, "DatePrototype");

            SetItem(GLOBAL, "prototype", new JSSimpleProperty("prototype", mPrototype));
        }
Example #3
0
        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();
        }
Example #4
0
        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();
        }
Example #5
0
        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();
        }
Example #6
0
 public static int getUTCMinutes(JSDate dt)
 {
     return dt.Value.ToUniversalTime().Minute;
 }
Example #7
0
 public static int getUTCFullYear(JSDate dt)
 {
     return dt.Value.ToUniversalTime().Year;
 }
Example #8
0
 public static int getUTCDate(JSDate dt)
 {
     return dt.Value.ToUniversalTime().Day;
 }
Example #9
0
 public static int getUTCMilliseconds(JSDate dt)
 {
     return(dt.Value.ToUniversalTime().Millisecond);
 }
Example #10
0
 public static string toUTCString(JSDate dt)
 {
     return dt.Value.ToUniversalTime().ToString();
 }
Example #11
0
 public static string toDateString(JSDate dt)
 {
     return dt.Value.ToLongDateString();
 }
Example #12
0
 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);
 }
Example #13
0
 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);
 }
Example #14
0
 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);
 }
Example #15
0
 public static void setTime(JSDate dt, long time)
 {
     dt.Value = new DateTime(time * 10000 + ((new DateTime(1970, 1, 1)).Ticks));
 }
Example #16
0
 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);
 }
Example #17
0
 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);
 }
Example #18
0
 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);
 }
Example #19
0
 public static int getUTCSeconds(JSDate dt)
 {
     return dt.Value.ToUniversalTime().Second;
 }
Example #20
0
 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();
 }
Example #21
0
 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);
 }
Example #22
0
 public static long parse(ExecutionContext GLOBAL, string date)
 {
     return(JSDate.getTime(new JSDate(GLOBAL, DateTime.Parse(date))));
 }
Example #23
0
 public static void setTime(JSDate dt, long time)
 {
     dt.Value = new DateTime(time * 10000 + ((new DateTime(1970, 1, 1)).Ticks));
 }
Example #24
0
 public static void setUTCMilliseconds(JSDate dt, int milliseconds)
 {
     setMilliseconds(dt, milliseconds);
 }
Example #25
0
 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();
 }
Example #26
0
 public static int getUTCHours(JSDate dt)
 {
     return(dt.Value.ToUniversalTime().Hour);
 }
Example #27
0
 public static string toLocaleString(JSDate dt)
 {
     return dt.Value.ToString();
 }
Example #28
0
 public static long getTime(JSDate dt)
 {
     return (dt.Value.Ticks - (new DateTime(1970, 1, 1)).Ticks) / 10000;
 }
Example #29
0
 public static int getDay(JSDate dt)
 {
     return (int)dt.Value.DayOfWeek;
 }
Example #30
0
 public static int getUTCMinutes(JSDate dt)
 {
     return(dt.Value.ToUniversalTime().Minute);
 }
Example #31
0
 public static int getSeconds(JSDate dt)
 {
     return dt.Value.Second;
 }
Example #32
0
 public static string toGMTString(JSDate dt)
 {
     return(toUTCString(dt));
 }
Example #33
0
 public static int getTimezoneOffset(JSDate dt)
 {
     return (int)((dt.Value.ToFileTime() - dt.Value.ToFileTimeUtc()) / 60 * 1000 * 10000);
 }
Example #34
0
 public static string toLocaleString(JSDate dt)
 {
     return(dt.Value.ToString());
 }
Example #35
0
 public static int getUTCDay(JSDate dt)
 {
     return (int)dt.Value.ToUniversalTime().DayOfWeek;
 }
Example #36
0
 public static string toDateString(JSDate dt)
 {
     return(dt.Value.ToLongDateString());
 }
Example #37
0
 public static int getUTCHours(JSDate dt)
 {
     return dt.Value.ToUniversalTime().Hour;
 }
Example #38
0
 public static string toTimeString(JSDate dt)
 {
     return(dt.Value.ToShortTimeString());
 }
Example #39
0
 public static int getUTCMonth(JSDate dt)
 {
     return dt.Value.ToUniversalTime().Month;
 }
Example #40
0
 public static string toUTCString(JSDate dt)
 {
     return(dt.Value.ToUniversalTime().ToString());
 }
Example #41
0
 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);
 }
Example #42
0
 public static long UTC(ExecutionContext GLOBAL)
 {
     return(JSDate.getTime(new JSDate(GLOBAL)));
 }
Example #43
0
 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);
 }
Example #44
0
 public static int getDate(JSDate dt)
 {
     return(dt.Value.Day);
 }
Example #45
0
 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);
 }
Example #46
0
 public static int getDay(JSDate dt)
 {
     return((int)dt.Value.DayOfWeek);
 }
Example #47
0
 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();
 }
Example #48
0
 public static int getFullYear(JSDate dt)
 {
     return(dt.Value.Year);
 }
Example #49
0
 public static void setUTCMilliseconds(JSDate dt, int milliseconds)
 {
     setMilliseconds(dt, milliseconds);
 }
Example #50
0
 public static int getHours(JSDate dt)
 {
     return(dt.Value.Hour);
 }
Example #51
0
 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);
 }
Example #52
0
 public static int getMilliseconds(JSDate dt)
 {
     return(dt.Value.Millisecond);
 }
Example #53
0
 public static string toGMTString(JSDate dt)
 {
     return toUTCString(dt);
 }
Example #54
0
 public static int getMinutes(JSDate dt)
 {
     return(dt.Value.Minute);
 }
Example #55
0
 public static string toTimeString(JSDate dt)
 {
     return dt.Value.ToShortTimeString();
 }
Example #56
0
        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;
        }
Example #57
0
 public static int getDate(JSDate dt)
 {
     return dt.Value.Day;
 }
Example #58
0
 public static int getMonth(JSDate dt)
 {
     return dt.Value.Month;
 }
Example #59
0
 public static int getFullYear(JSDate dt)
 {
     return dt.Value.Year;
 }
Example #60
0
 public static int getUTCFullYear(JSDate dt)
 {
     return(dt.Value.ToUniversalTime().Year);
 }