private static void SetDateTime(LTime target, DateTimeKind kind, int year = -1, int month = -1, int day = -1, int hour = -1, int minute = -1, int second = -1, int millisecond = -1) { var t = target.Value; hour = hour == -1 ? t.Hours : hour; minute = minute == -1 ? t.Minutes : minute; second = second == -1 ? t.Seconds : second; millisecond = millisecond == -1 ? t.Milliseconds : millisecond; var finaLTimeTime = new TimeSpan(hour, minute, second, millisecond); target.Value = finaLTimeTime; }
public int GetDays(LTime target) { var date = target.Value; return date.Days; }
public string ToString(LTime target) { var date = target.Value; return date.ToString("hh mm ss"); }
/// <summary> /// Sets the seconds on the date /// </summary> /// <param name="time">The LTimeType to set</param> /// <param name="seconds">The seconds to set</param> /// <param name="milliseconds">The milliseconds to set</param> public void SetSeconds(LTime time, int seconds, int milliseconds) { SetDateTime(time, DateTimeKind.Local, -1, -1, -1, -1, -1, seconds, milliseconds); }
/// <summary> /// Sets the hours of the date /// </summary> /// <param name="time">The LTimeType 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 SetHours(LTime time, int hours, int minutes, int seconds, int milliseconds) { SetDateTime(time, DateTimeKind.Local, -1, -1, -1, hours, minutes, seconds, milliseconds); }
/// <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 CompareTimes(AstNode node, LTime lhs, LTime 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); }
public int GetMinutes(LTime target) { var date = target.Value; return date.Minutes; }
public int GetMinutes(LTime target) { var date = target.Value; return(date.Minutes); }
public int GetMilliseconds(LTime target) { var date = target.Value; return(date.Milliseconds); }
public int GetHours(LTime target) { var date = target.Value; return(date.Hours); }
public int GetDays(LTime target) { var date = target.Value; return(date.Days); }
/// <summary> /// Sets the milliseconds on the date /// </summary> /// <param name="time">The LTimeType to set</param> /// <param name="milliseconds">The milliseconds to set</param> public void SetMilliseconds(LTime time, int milliseconds) { SetDateTime(time, DateTimeKind.Local, -1, -1, -1, -1, -1, -1, milliseconds); }
public int GetHours(LTime target) { var date = target.Value; return date.Hours; }
public int GetSeconds(LTime target) { var date = target.Value; return(date.Seconds); }
public int GetMilliseconds(LTime target) { var date = target.Value; return date.Milliseconds; }
public string ToString(LTime target) { var date = target.Value; return(date.ToString("hh mm ss")); }
public int GetSeconds(LTime target) { var date = target.Value; return date.Seconds; }
/// <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 CalcTimes(AstNode node, LTime lhs, LTime rhs, Operator op) { if (op != Operator.Add && op != Operator.Subtract) throw ExceptionHelper.BuildRunTimeException(node, "Can only add/subtract times"); var left = lhs.Value; var right = rhs.Value; var result = TimeSpan.MinValue; if (op == Operator.Add) { result = left + right; } else if (op == Operator.Subtract) { result = left - right; } return new LTime(result); }