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

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