/// <summary> /// Evaluates a math expression of 2 time spans. /// </summary> /// <param name="node">The AST node the evaluation is a part of.</param> /// <param name="lhs">The time on the left hand side</param> /// <param name="rhs">The time on the right hand side</param> /// <param name="op">The math operator.</param> /// <returns></returns> public static LTime CalcDates(AstNode node, LDate lhs, LDate rhs, Operator op) { if (op != Operator.Subtract) throw ExceptionHelper.BuildRunTimeException(node, "Can only subtract dates"); var left = lhs.Value; var right = rhs.Value; var result = left - right; return new LTime(result); }
private static void SetDateTime(LDate date, DateTimeKind kind, int year = -1, int month = -1, int day = -1, int hour = -1, int minute = -1, int second = -1, int millisecond = -1) { var target = date.Value; var dt = kind == DateTimeKind.Utc ? target.ToUniversalTime() : target; year = year == -1 ? dt.Year : year; month = month == -1 ? dt.Month : month; day = day == -1 ? dt.Day : day; hour = hour == -1 ? dt.Hour : hour; minute = minute == -1 ? dt.Minute : minute; second = second == -1 ? dt.Second : second; millisecond = millisecond == -1 ? dt.Millisecond : millisecond; var finalDateTime = new DateTime(year, month, day, hour, minute, second, millisecond, kind); date.Value = finalDateTime; }
public string ToTimeString (LDate target) { var date = target.Value; return date.ToString("hh mm ss"); }
public int GetUtcHours (LDate target) { var date = target.Value; return date.ToUniversalTime().Hour; }
public int GetMilliseconds(LDate target) { var date = target.Value; return(date.Millisecond); }
public int GetHours (LDate target) { var date = target.Value; return date.Hour; }
public int GetSeconds (LDate target) { var date = target.Value; return date.Second; }
/// <summary> /// Sets the month on the date. /// </summary> /// <param name="date">The LDateType to set</param> /// <param name="month">The month to set</param> /// <param name="day">The day of the month to set</param> public void SetUtcMonth(LDate date, int month, int day) { SetDateTime(date, DateTimeKind.Utc, -1, month, day); }
private static void SetDateTime(LDate date, DateTimeKind kind, int year = -1, int month = -1, int day = -1, int hour = -1, int minute = -1, int second = -1, int millisecond = -1) { var target = date.Value; DateTime dt = kind == DateTimeKind.Utc ? target.ToUniversalTime() : target; year = year == -1 ? dt.Year : year; month = month == -1 ? dt.Month : month; day = day == -1 ? dt.Day : day; hour = hour == -1 ? dt.Hour : hour; minute = minute == -1 ? dt.Minute : minute; second = second == -1 ? dt.Second : second; millisecond = millisecond == -1 ? dt.Millisecond : millisecond; var finalDateTime = new DateTime(year, month, day, hour, minute, second, millisecond, kind); date.Value = finalDateTime; }
public int GetUtcFullYear(LDate target) { var date = target.Value; return(date.ToUniversalTime().Year); }
public int GetUtcHours(LDate target) { var date = target.Value; return(date.ToUniversalTime().Hour); }
public int GetUtcDate(LDate target) { var date = target.Value; return(date.ToUniversalTime().Day); }
public int GetUtcDay(LDate target) { var date = target.Value; return((int)date.ToUniversalTime().DayOfWeek); }
public int GetSeconds(LDate target) { var date = target.Value; return(date.Second); }
public int GetMonth(LDate target) { var date = target.Value; return(date.Month); }
public int GetMinutes(LDate target) { var date = target.Value; return(date.Minute); }
/// <summary> /// Sets the month on the date. /// </summary> /// <param name="date">The LDateType to set</param> /// <param name="month">The month to set</param> /// <param name="day">The day of the month to set</param> public void SetMonth(LDate date, int month, int day) { SetDateTime(date, DateTimeKind.Local, -1, month, day); }
public int GetUtcMinutes(LDate target) { var date = target.Value; return(date.ToUniversalTime().Minute); }
/// <summary> /// Sets the milliseconds on the date /// </summary> /// <param name="date">The LDateType to set</param> /// <param name="milliseconds">The milliseconds to set</param> public void SetMilliseconds(LDate date, int milliseconds) { SetDateTime(date, DateTimeKind.Local, -1, -1, -1, -1, -1, -1, milliseconds); }
public int GetUtcMonth(LDate target) { var date = target.Value; return(date.ToUniversalTime().Month); }
/// <summary> /// Sets the hours on the date. /// </summary> /// <param name="date">The LDateType to set</param> /// <param name="hours">The hours to set</param> /// <param name="minutes">The minutes to set</param> /// <param name="seconds">The seconds to set</param> /// <param name="milliseconds">The milliseconds to set</param> public void SetUtcHours(LDate date, int hours, int minutes, int seconds, int milliseconds) { SetDateTime(date, DateTimeKind.Utc, -1, -1, -1, hours, minutes, seconds, milliseconds); }
public int GetUtcSeconds(LDate target) { var date = target.Value; return(date.ToUniversalTime().Second); }
public int GetDay (LDate target) { var date = target.Value; return (int)date.DayOfWeek; }
public string ToLocaleDateString(LDate target) { var date = target.Value; return(date.ToLocalTime().ToString("ddd MMM dd yyyy")); }
public int GetMinutes (LDate target) { var date = target.Value; return date.Minute; }
public int GetUtcMinutes (LDate target) { var date = target.Value; return date.ToUniversalTime().Minute; }
public int GetUtcDay (LDate target) { var date = target.Value; return (int)date.ToUniversalTime().DayOfWeek; }
public string ToLocaleDateString (LDate target) { var date = target.Value; return date.ToLocalTime().ToString("ddd MMM dd yyyy"); }
public string ToString(LDate target) { var date = target.Value; return(date.ToString("ddd MMM dd yyyy hh mm ss")); }
public int GetHours(LDate target) { var date = target.Value; return(date.Hour); }
public int GetUtcMonth (LDate target) { var date = target.Value; return date.ToUniversalTime().Month; }
public string ToTimeString(LDate target) { var date = target.Value; return(date.ToString("hh mm ss")); }
public string ToString (LDate target) { var date = target.Value; return date.ToString("ddd MMM dd yyyy hh mm ss"); }
public string ToUtcString(LDate target) { var date = target.Value; return(date.ToUniversalTime().ToString("ddd MMM dd yyyy hh mm ss")); }
public string ToUtcString (LDate target) { var date = target.Value; return date.ToUniversalTime().ToString("ddd MMM dd yyyy hh mm ss"); }
/// <summary> /// Sets the day of the month on the date /// </summary> /// <param name="date">The LDateType to set</param> /// <param name="day">The day of the month to set</param> public void SetDate(LDate date, int day) { SetDateTime(date, DateTimeKind.Local, -1, -1, day); }
/// <summary> /// Sets the full year on the date. /// </summary> /// <param name="date">The LDateType to set</param> /// <param name="year">The year to set</param> /// <param name="month">The month to set</param> /// <param name="day">The day of the month to set</param> public void SetUtcFullYear(LDate date, int year, int month, int day) { SetDateTime(date, DateTimeKind.Utc, year, month, day); }
/// <summary> /// Sets the day of the month on the date. /// </summary> /// <param name="date">The LDateType to set</param> /// <param name="day">The day of the month to set</param> public void SetUtcDate(LDate date, int day) { SetDateTime(date, DateTimeKind.Utc, -1, -1, day); }
/// <summary> /// Sets the milliseconds on the date. /// </summary> /// <param name="date">The LDateType to set</param> /// <param name="milliseconds">The milliseconds to set</param> public void SetUtcMilliseconds(LDate date, int milliseconds) { SetDateTime(date, DateTimeKind.Utc, -1, -1, -1, -1, -1, -1, milliseconds); }
public int GetDate (LDate target) { var date = target.Value; return date.Day; }
public int GetFullYear (LDate target) { var date = target.Value; return date.Year; }
public int GetMilliseconds (LDate target) { var date = target.Value; return date.Millisecond; }
public int GetMonth (LDate target) { var date = target.Value; return date.Month; }
public int GetDate(LDate target) { var date = target.Value; return(date.Day); }
public int GetUtcDate (LDate target) { var date = target.Value; return date.ToUniversalTime().Day; }
public int GetDay(LDate target) { var date = target.Value; return((int)date.DayOfWeek); }
public int GetUtcFullYear (LDate target) { var date = target.Value; return date.ToUniversalTime().Year; }
public int GetFullYear(LDate target) { var date = target.Value; return(date.Year); }
public int GetUtcMilliseconds (LDate target) { var date = target.Value; return date.ToUniversalTime().Millisecond; }
/// <summary> /// Evaluates a math expression of 2 time spans. /// </summary> /// <param name="node">The AST node the evaluation is a part of.</param> /// <param name="lhs">The time on the left hand side</param> /// <param name="rhs">The time on the right hand side</param> /// <param name="op">The math operator.</param> /// <returns></returns> public static LBool CompareDates(AstNode node, LDate lhs, LDate rhs, Operator op) { var left = lhs.Value; var right = rhs.Value; var result = false; if (op == Operator.LessThan) result = left < right; else if (op == Operator.LessThanEqual) result = left <= right; else if (op == Operator.MoreThan) result = left > right; else if (op == Operator.MoreThanEqual) result = left >= right; else if (op == Operator.EqualEqual) result = left == right; else if (op == Operator.NotEqual) result = left != right; return new LBool(result); }