Пример #1
0
        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;
        }
Пример #2
0
 public int GetDays(LTime target)
 {
     var date = target.Value; return date.Days;
 }
Пример #3
0
        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;
        }
Пример #4
0
 public string ToString(LTime target)
 {
     var date = target.Value; return date.ToString("hh mm ss");
 }
Пример #5
0
 /// <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);
 }
Пример #6
0
 /// <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);
 }
Пример #7
0
 /// <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);
 }
Пример #8
0
 public int GetMinutes(LTime target)
 {
     var date = target.Value; return date.Minutes;
 }
Пример #9
0
 public int GetMinutes(LTime target)
 {
     var date = target.Value; return(date.Minutes);
 }
Пример #10
0
 public int GetMilliseconds(LTime target)
 {
     var date = target.Value; return(date.Milliseconds);
 }
Пример #11
0
 public int GetHours(LTime target)
 {
     var date = target.Value; return(date.Hours);
 }
Пример #12
0
 public int GetDays(LTime target)
 {
     var date = target.Value; return(date.Days);
 }
Пример #13
0
 /// <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);
 }
Пример #14
0
 /// <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);
 }
Пример #15
0
 public int GetHours(LTime target)
 {
     var date = target.Value; return date.Hours;
 }
Пример #16
0
 public int GetSeconds(LTime target)
 {
     var date = target.Value; return(date.Seconds);
 }
Пример #17
0
 public int GetMilliseconds(LTime target)
 {
     var date = target.Value; return date.Milliseconds;
 }
Пример #18
0
 public string ToString(LTime target)
 {
     var date = target.Value; return(date.ToString("hh mm ss"));
 }
Пример #19
0
 public int GetSeconds(LTime target)
 {
     var date = target.Value; return date.Seconds;
 }
Пример #20
0
        /// <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);
        }