Exemplo n.º 1
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 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);
        }
Exemplo n.º 2
0
        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;
        }
Exemplo n.º 3
0
 public string   ToTimeString         (LDate target) { var date = target.Value; return date.ToString("hh mm ss");                                     }
Exemplo n.º 4
0
 public int      GetUtcHours          (LDate target) { var date = target.Value; return date.ToUniversalTime().Hour;                                   }
Exemplo n.º 5
0
 public int GetMilliseconds(LDate target)
 {
     var date = target.Value; return(date.Millisecond);
 }
Exemplo n.º 6
0
 public int      GetHours             (LDate target) { var date = target.Value; return date.Hour;                                                     }
Exemplo n.º 7
0
 public int      GetSeconds           (LDate target) { var date = target.Value; return date.Second;                                                   }
Exemplo n.º 8
0
 /// <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);
 }
Exemplo n.º 9
0
        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;
        }
Exemplo n.º 10
0
 public int GetUtcFullYear(LDate target)
 {
     var date = target.Value; return(date.ToUniversalTime().Year);
 }
Exemplo n.º 11
0
 public int GetUtcHours(LDate target)
 {
     var date = target.Value; return(date.ToUniversalTime().Hour);
 }
Exemplo n.º 12
0
 public int GetUtcDate(LDate target)
 {
     var date = target.Value; return(date.ToUniversalTime().Day);
 }
Exemplo n.º 13
0
 public int GetUtcDay(LDate target)
 {
     var date = target.Value; return((int)date.ToUniversalTime().DayOfWeek);
 }
Exemplo n.º 14
0
 public int GetSeconds(LDate target)
 {
     var date = target.Value; return(date.Second);
 }
Exemplo n.º 15
0
 public int GetMonth(LDate target)
 {
     var date = target.Value; return(date.Month);
 }
Exemplo n.º 16
0
 public int GetMinutes(LDate target)
 {
     var date = target.Value; return(date.Minute);
 }
Exemplo n.º 17
0
 /// <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);
 }
Exemplo n.º 18
0
 public int GetUtcMinutes(LDate target)
 {
     var date = target.Value; return(date.ToUniversalTime().Minute);
 }
Exemplo n.º 19
0
 /// <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);
 }
Exemplo n.º 20
0
 public int GetUtcMonth(LDate target)
 {
     var date = target.Value; return(date.ToUniversalTime().Month);
 }
Exemplo n.º 21
0
 /// <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);
 }
Exemplo n.º 22
0
 public int GetUtcSeconds(LDate target)
 {
     var date = target.Value; return(date.ToUniversalTime().Second);
 }
Exemplo n.º 23
0
 public int      GetDay               (LDate target) { var date = target.Value; return (int)date.DayOfWeek;                                           }
Exemplo n.º 24
0
 public string ToLocaleDateString(LDate target)
 {
     var date = target.Value; return(date.ToLocalTime().ToString("ddd MMM dd yyyy"));
 }
Exemplo n.º 25
0
 public int      GetMinutes           (LDate target) { var date = target.Value; return date.Minute;		                                           }
Exemplo n.º 26
0
 public int      GetUtcMinutes        (LDate target) { var date = target.Value; return date.ToUniversalTime().Minute;                                 }
Exemplo n.º 27
0
 public int      GetUtcDay            (LDate target) { var date = target.Value; return (int)date.ToUniversalTime().DayOfWeek;                         }
Exemplo n.º 28
0
 public string   ToLocaleDateString   (LDate target) { var date = target.Value; return date.ToLocalTime().ToString("ddd MMM dd yyyy");                }
Exemplo n.º 29
0
 public string ToString(LDate target)
 {
     var date = target.Value; return(date.ToString("ddd MMM dd yyyy hh mm ss"));
 }
Exemplo n.º 30
0
 public int GetHours(LDate target)
 {
     var date = target.Value; return(date.Hour);
 }
Exemplo n.º 31
0
 public int      GetUtcMonth          (LDate target) { var date = target.Value; return date.ToUniversalTime().Month;                                  }
Exemplo n.º 32
0
 public string ToTimeString(LDate target)
 {
     var date = target.Value; return(date.ToString("hh mm ss"));
 }
Exemplo n.º 33
0
 public string   ToString             (LDate target) { var date = target.Value; return date.ToString("ddd MMM dd yyyy hh mm ss");                     }
Exemplo n.º 34
0
 public string ToUtcString(LDate target)
 {
     var date = target.Value; return(date.ToUniversalTime().ToString("ddd MMM dd yyyy hh mm ss"));
 }
Exemplo n.º 35
0
 public string   ToUtcString          (LDate target) { var date = target.Value; return date.ToUniversalTime().ToString("ddd MMM dd yyyy hh mm ss");   }
Exemplo n.º 36
0
 /// <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);
 }
Exemplo n.º 37
0
 /// <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);
 }
Exemplo n.º 38
0
 /// <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);
 }
Exemplo n.º 39
0
 /// <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);
 }
Exemplo n.º 40
0
 /// <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);
 }
Exemplo n.º 41
0
 /// <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);
 }
Exemplo n.º 42
0
 /// <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);
 }
Exemplo n.º 43
0
 /// <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);
 }
Exemplo n.º 44
0
 /// <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);
 }
Exemplo n.º 45
0
 public int      GetDate              (LDate target) { var date = target.Value; return date.Day;                                                      }      	
Exemplo n.º 46
0
 /// <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);
 }
Exemplo n.º 47
0
 public int      GetFullYear          (LDate target) { var date = target.Value; return date.Year;                                                     }
Exemplo n.º 48
0
 /// <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);
 }
Exemplo n.º 49
0
 public int      GetMilliseconds      (LDate target) { var date = target.Value; return date.Millisecond;                                              }
Exemplo n.º 50
0
 /// <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);
 }
Exemplo n.º 51
0
 public int      GetMonth             (LDate target) { var date = target.Value; return date.Month;                                                    }
Exemplo n.º 52
0
 public int GetDate(LDate target)
 {
     var date = target.Value; return(date.Day);
 }
Exemplo n.º 53
0
 public int      GetUtcDate           (LDate target) { var date = target.Value; return date.ToUniversalTime().Day;                                    }
Exemplo n.º 54
0
 public int GetDay(LDate target)
 {
     var date = target.Value; return((int)date.DayOfWeek);
 }
Exemplo n.º 55
0
 public int      GetUtcFullYear       (LDate target) { var date = target.Value; return date.ToUniversalTime().Year;                                   }
Exemplo n.º 56
0
 public int GetFullYear(LDate target)
 {
     var date = target.Value; return(date.Year);
 }
Exemplo n.º 57
0
 public int      GetUtcMilliseconds   (LDate target) { var date = target.Value; return date.ToUniversalTime().Millisecond;                            }  
Exemplo n.º 58
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 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);
 }