コード例 #1
0
        public static string toUTCString(object thisObj)
        {
            SemanticAnalyser.assert_type(thisObj, typeof(DateObject));

            DateObject date_obj = (DateObject)thisObj;
            double     val      = date_obj.ms;
            int        year     = DateConstructor.YearFromTime(val);
            int        month    = DateConstructor.MonthFromTime(val);
            int        date     = DateConstructor.DateFromTime(val);
            int        hour     = DateConstructor.HourFromTime(val);
            int        min      = DateConstructor.MinFromTime(val);
            int        sec      = DateConstructor.SecFromTime(val);

            DateTime dt;

            try {
                dt = new DateTime(year, month + 1, date);
            } catch (ArgumentOutOfRangeException) {
                return(InvalidDateString);
            }

            string date_string = dt.ToString("ddd, d MMM yyyy ", CultureInfo.InvariantCulture);
            string time_string = String.Format(@"{0:00}:{1:00}:{2:00} UTC", hour, min, sec);

            return(date_string + time_string);
        }
コード例 #2
0
        public static double setUTCDate(object thisObj, double ddate)
        {
            SemanticAnalyser.assert_type(thisObj, typeof(DateObject));
            DateObject date = (DateObject)thisObj;
            double     t    = date.ms;
            double     day  = DateConstructor.MakeDay((double)DateConstructor.YearFromTime(t),
                                                      (double)DateConstructor.MonthFromTime(t), ddate);
            double new_val = DateConstructor.MakeDate(day, t % DateConstructor.MS_PER_DAY);

            date.ms = DateConstructor.TimeClip(new_val);
            return(date.ms);
        }
コード例 #3
0
        public static double getUTCMonth(object thisObj)
        {
            SemanticAnalyser.assert_type(thisObj, typeof(DateObject));

            DateObject date = (DateObject)thisObj;
            double     val  = date.ms;

            if (Double.IsNaN(val))
            {
                return(Double.NaN);
            }
            else
            {
                return(DateConstructor.MonthFromTime(val));
            }
        }
コード例 #4
0
        public static string toLocaleDateString(object thisObj)
        {
            SemanticAnalyser.assert_type(thisObj, typeof(DateObject));

            DateObject date_obj = (DateObject)thisObj;
            double     val      = date_obj.ms;
            double     lv       = DateConstructor.LocalTime(val);
            int        year     = DateConstructor.YearFromTime(lv);
            int        month    = DateConstructor.MonthFromTime(lv);
            int        date     = DateConstructor.DateFromTime(lv);

            DateTime dt;

            try {
                dt = new DateTime(year, month + 1, date);
            } catch (ArgumentOutOfRangeException) {
                return(InvalidDateString);
            }

            return(dt.ToString("D"));
        }
コード例 #5
0
        public static double setUTCFullYear(object thisObj, double dyear,
                                            object month, object date)
        {
            SemanticAnalyser.assert_type(thisObj, typeof(DateObject));
            DateObject dt = (DateObject)thisObj;
            double     t  = dt.ms;

            if (Double.IsNaN(t))
            {
                t = 0;
            }

            double new_month;

            if (month == null)
            {
                new_month = DateConstructor.MonthFromTime(t);
            }
            else
            {
                new_month = Convert.ToNumber(month);
            }

            double new_date;

            if (date == null)
            {
                new_date = DateConstructor.DateFromTime(t);
            }
            else
            {
                new_date = Convert.ToNumber(date);
            }

            double day     = DateConstructor.MakeDay(dyear, new_month, new_date);
            double new_val = DateConstructor.MakeDate(day, t % DateConstructor.MS_PER_DAY);

            dt.ms = DateConstructor.TimeClip(new_val);
            return(dt.ms);
        }