public static Altova.Types.DateTime DatetimeFromParts(int year, int month, int day, int hour, int minute, int second, decimal millisecond, int timezone) { Altova.Types.DateTime result = DatetimeAdd(new Altova.Types.DateTime(1, 1, 1), new Altova.Types.Duration(year - 1, month - 1, day - 1, hour, minute, second, (double)(millisecond * 0.001m), false)); // false means "not-negative" if (timezone >= -1440 && timezone <= 1440) { result.TimezoneOffset = (short)timezone; } return(result); }
public static int Weekday(Altova.Types.DateTime dt) // 1=sunday,... //{ return (int) dt.Value.DayOfWeek; } { long a = (14 - dt.Value.Month) / 12; long m = dt.Value.Month + 12 * a - 3; long y = dt.Value.Year + 4800 - a; long JD = dt.Value.Day + (153 * m + 2) / 5 + y * 365 + y / 4 - y / 100 + y / 400 - 32045; // julian date return((int)(JD % 7 + 1)); }
public static Altova.Types.DateTime DatetimeFromDateAndTime(Altova.Types.DateTime date, Altova.Types.DateTime time) { Altova.Types.DateTime ret = new Altova.Types.DateTime(date); System.DateTime sysdt = ret.Value; sysdt = sysdt.AddHours(-date.Value.Hour + time.Value.Hour); sysdt = sysdt.AddMinutes(-date.Value.Minute + time.Value.Minute); sysdt = sysdt.AddSeconds(-date.Value.Second + time.Value.Second); sysdt = sysdt.AddMilliseconds(-date.Value.Millisecond + time.Value.Millisecond); ret.Value = sysdt; return(ret); }
public static double DatetimeToXLSX(Altova.Types.DateTime o) { Altova.Types.DateTime dt = new Altova.Types.DateTime(o); dt.TimezoneOffset = 0; double result = TimeToXLSX(dt); if (result >= 60) { result++; } return(++result); }
public static int Weeknumber(Altova.Types.DateTime dt) { long a = (14 - dt.Value.Month) / 12; long m = dt.Value.Month + 12 * a - 3; long y = dt.Value.Year + 4800 - a; long JD = dt.Value.Day + (153 * m + 2) / 5 + y * 365 + y / 4 - y / 100 + y / 400 - 32045; long d4 = (JD + 31741 - (JD % 7)) % 146097 % 36524 % 1461; long L = d4 / 1460; long d1 = ((d4 - L) % 365) + L; return((int)(d1 / 7 + 1)); }
public static Altova.Types.DateTime XLSXToDate(double o) { int days = (int)o; Altova.Types.DateTime result = new Altova.Types.DateTime(1900, 1, 1); days--; if (days >= 60) { days--; } return(Lang.DatetimeAdd(new Altova.Types.DateTime(1900, 1, 1), new Altova.Types.Duration(0, 0, days, 0, 0, 0, 0.0, false))); }
public static Altova.Types.Duration DatetimeDiff(Altova.Types.DateTime a, Altova.Types.DateTime b) { Altova.Types.Duration dur = new Altova.Types.Duration(a.Value.Ticks - b.Value.Ticks); int timezoneOffset = 0; if (a.HasTimezone) { timezoneOffset -= (int)a.TimezoneOffset; } if (b.HasTimezone) { timezoneOffset += (int)b.TimezoneOffset; } if (timezoneOffset != 0) { dur.Value = dur.Value.Add(new System.TimeSpan(0, timezoneOffset, 0)); } return(dur); }
public static int MonthFromDatetime(Altova.Types.DateTime dt) { return(dt.Value.Month); }
public static bool Numeric(Altova.Types.DateTime dt) { return(false); }
public static int Timezone(Altova.Types.DateTime dt) { return(dt.TimezoneOffset); }
public static bool Leapyear(Altova.Types.DateTime dt) { int year = dt.Value.Year; return((year % 4 == 0 && year % 100 != 0) || year % 400 == 0); }
public override string Format(DateTime dt) { return dt.ToString(Altova.Types.DateTimeFormat.W3_time); }
public static double TimeToXLSX(Altova.Types.DateTime o) { Altova.Types.Duration diff = Lang.DatetimeDiff(o, new Altova.Types.DateTime(1900, 1, 1)); return((double)diff.Value.TotalMilliseconds / 86400000.0); }
public static bool EqualOrLess(Altova.Types.DateTime a, Altova.Types.DateTime b) { return(a <= b); }
public static bool Less(Altova.Types.DateTime a, Altova.Types.DateTime b) { return(a < b); }
public static string ToString(Altova.Types.DateTime dt) { return(Altova.CoreTypes.CastToString(dt)); }
public static Altova.Types.DateTime TimeFromDatetime(Altova.Types.DateTime dt) { return(DatetimeFromParts(1, 1, 1, dt.Value.Hour, dt.Value.Minute, dt.Value.Second, dt.Value.Millisecond, dt.TimezoneOffset)); }
public static Altova.Types.DateTime DateFromDatetime(Altova.Types.DateTime dt) { return(DatetimeFromParts(dt.Value.Year, dt.Value.Month, dt.Value.Day, 0, 0, 0, 0.0m, dt.TimezoneOffset)); }
public static Altova.Types.DateTime DatetimeAdd(Altova.Types.DateTime a, Altova.Types.Duration b) { Altova.Types.DateTime dt = new Altova.Types.DateTime(new System.DateTime(a.Value.AddMonths(b.Years * 12 + b.Months).Ticks + b.Value.Ticks)); dt.TimezoneOffset = a.TimezoneOffset; return(dt); }
public static bool Greater(Altova.Types.DateTime a, Altova.Types.DateTime b) { return(a > b); }
public static int DayFromDatetime(Altova.Types.DateTime dt) { return(dt.Value.Day); }
public static bool EqualOrGreater(Altova.Types.DateTime a, Altova.Types.DateTime b) { return(a >= b); }
public static int HourFromDatetime(Altova.Types.DateTime dt) { return(dt.Value.Hour); }
public static bool NotEqual(Altova.Types.DateTime a, Altova.Types.DateTime b) { return(a != b); }
public static int MinuteFromDatetime(Altova.Types.DateTime dt) { return(dt.Value.Minute); }
public static int SecondFromDatetime(Altova.Types.DateTime dt) { return(dt.Value.Second); }
public static decimal MillisecondFromDatetime(Altova.Types.DateTime dt) { return((decimal)dt.Value.Millisecond); }
public static double DateToXLSX(Altova.Types.DateTime o) { return(DatetimeToXLSX(o)); }
public virtual string Format(DateTime v) { return CoreTypes.CastToString(v); }