public static double setUTCSeconds(object thisObj, double dsec, object msec) { SemanticAnalyser.assert_type(thisObj, typeof(DateObject)); DateObject date = (DateObject)thisObj; double t = date.ms; double new_ms; if (msec == null) { new_ms = DateConstructor.msFromTime(t); } else { new_ms = Convert.ToNumber(msec); } double time = DateConstructor.MakeTime(DateConstructor.HourFromTime(t), DateConstructor.MinFromTime(t), dsec, new_ms); double day = Math.Floor(t / DateConstructor.MS_PER_DAY); double new_val = DateConstructor.MakeDate(day, time); date.ms = DateConstructor.TimeClip(new_val); return(date.ms); }
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); }
public static string toTimeString(object thisObj) { SemanticAnalyser.assert_type(thisObj, typeof(DateObject)); DateObject date_obj = (DateObject)thisObj; double val = date_obj.ms; double lv = DateConstructor.LocalTime(val); int hour = DateConstructor.HourFromTime(lv); int min = DateConstructor.MinFromTime(lv); int sec = DateConstructor.SecFromTime(lv); double off = getTimezoneOffset(thisObj); return(String.Format(@"{0:00}:{1:00}:{2:00} UTC{3:\+0;\-0;\+0}", hour, min, sec, -off / 60)); }
public static double getUTCMinutes(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.MinFromTime(val)); } }
public static double setHours(object thisObj, double dhour, object min, object sec, object msec) { SemanticAnalyser.assert_type(thisObj, typeof(DateObject)); DateObject date = (DateObject)thisObj; double t = DateConstructor.LocalTime(date.ms); double new_min; if (min == null) { new_min = DateConstructor.MinFromTime(t); } else { new_min = Convert.ToNumber(min); } double new_sec; if (sec == null) { new_sec = DateConstructor.SecFromTime(t); } else { new_sec = Convert.ToNumber(sec); } double new_ms; if (msec == null) { new_ms = DateConstructor.msFromTime(t); } else { new_ms = Convert.ToNumber(msec); } double time = DateConstructor.MakeTime(dhour, new_min, new_sec, new_ms); double day = Math.Floor(t / DateConstructor.MS_PER_DAY); double new_val = DateConstructor.ToUTC(DateConstructor.MakeDate(day, time)); date.ms = DateConstructor.TimeClip(new_val); return(date.ms); }
public static string toLocaleTimeString(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); int hour = DateConstructor.HourFromTime(lv); int min = DateConstructor.MinFromTime(lv); int sec = DateConstructor.SecFromTime(lv); DateTime dt; try { dt = new DateTime(year, month + 1, date, hour, min, sec); } catch (ArgumentOutOfRangeException) { return(InvalidDateString); } return(dt.ToString("T")); }
public static double setUTCMilliseconds(object thisObj, double msec) { SemanticAnalyser.assert_type(thisObj, typeof(DateObject)); DateObject date = (DateObject)thisObj; double t = date.ms; double time = DateConstructor.MakeTime(DateConstructor.HourFromTime(t), DateConstructor.MinFromTime(t), DateConstructor.SecFromTime(t), msec); double day = Math.Floor(t / DateConstructor.MS_PER_DAY); double new_val = DateConstructor.MakeDate(day, time); date.ms = DateConstructor.TimeClip(new_val); return(date.ms); }