예제 #1
0
        public override decimal ToTimeVariable(TimeVariableType type)
        {
            switch (type)
            {
            case TimeVariableType.Year:
                return(DateTime.Now.AddDays(-1).Year);

            case TimeVariableType.Month:
                return(DateTime.Now.AddDays(-1).Month);

            case TimeVariableType.Day:
                return(DateTime.Now.AddDays(-1).Day);

            case TimeVariableType.WeekDay:
                return(DateExtractor.GetWeekDay(ToTime()));

            case TimeVariableType.Hour:
                return((int)arg0.ToNumber());

            case TimeVariableType.Minute:
                return((int)arg1.ToNumber());

            case TimeVariableType.Second:
                return((int)arg2.ToNumber());
            }
            return(0);
        }
예제 #2
0
        public override decimal ToTimeVariable(TimeVariableType type)
        {
            switch (type)
            {
            case TimeVariableType.Year:
                return(arg0.ToNumber());

            case TimeVariableType.Month:
                return(1);

            case TimeVariableType.Day:
                return(1);

            case TimeVariableType.WeekDay:
                return(DateExtractor.GetWeekDay(ToTime()));

            case TimeVariableType.Hour:
                return(0);

            case TimeVariableType.Minute:
                return(0);

            case TimeVariableType.Second:
                return(0);
            }
            return(0);
        }
예제 #3
0
 public OrderByStructTime(OrderByVariable var, TimeVariableType tim)
     : base(var)
 {
     variable = var;
     time     = tim;
     type     = OrderByType.ASC;
 }
예제 #4
0
        public override decimal ToTimeVariable(TimeVariableType type)
        {
            switch (type)
            {
            case TimeVariableType.Year:
                return(year.ToYear());

            case TimeVariableType.Month:
                return(month);

            case TimeVariableType.Day:
                return(day.ToDay());

            case TimeVariableType.WeekDay:
                return(DateExtractor.GetWeekDay(ToTime()));

            case TimeVariableType.Hour:
                return(clock.ToHour());

            case TimeVariableType.Minute:
                return(clock.ToMinute());

            case TimeVariableType.Second:
                return(clock.ToSecond());
            }
            return(0);
        }
예제 #5
0
        public static decimal GetVariable(DateTime time, TimeVariableType type)
        {
            switch (type)
            {
            case TimeVariableType.Year:
                return(time.Year);

            case TimeVariableType.Month:
                return(time.Month);

            case TimeVariableType.Day:
                return(time.Day);

            case TimeVariableType.WeekDay:
                return(GetWeekDay(time));

            case TimeVariableType.Hour:
                return(time.Hour);

            case TimeVariableType.Minute:
                return(time.Minute);

            case TimeVariableType.Second:
                return(time.Second);
            }
            return(0);
        }
예제 #6
0
 public void SetElementOfTime(string name, decimal value, TimeVariableType type)
 {
     if (variables.Where(v => v.GetName().Equals(name)).Count() == 1)
     {
         Named nv = variables.First(v => v.GetName().Equals(name));
         if (nv is TimeVariable)
         {
             (nv as TimeVariable).SetElementValue(value, type);
         }
     }
 }
예제 #7
0
        public void SetElementValue(decimal newValue, TimeVariableType type)
        {
            switch (type)
            {
            case TimeVariableType.Year:
            {
                TimeValidator.ValidateYear((int)newValue);
                ChangeYear((int)newValue);     // special method considering leap years
                break;
            }

            case TimeVariableType.Month:
            {
                TimeValidator.ValidateMonth((int)newValue);
                TimeValidator.ValidateDay(value.Day, (int)newValue, value.Day);
                value = new DateTime(value.Year, (int)newValue, value.Day);
                break;
            }

            case TimeVariableType.Day:
            {
                TimeValidator.ValidateDay(value.Day, value.Month, (int)newValue);
                value = new DateTime(value.Year, value.Month, (int)newValue);
                break;
            }

            case TimeVariableType.Hour:
            {
                TimeValidator.ValidateHour((int)newValue);
                TimeSpan ts = new TimeSpan((int)newValue, value.Minute, value.Second);
                value = value.Date + ts;
                break;
            }

            case TimeVariableType.Minute:
            {
                TimeValidator.ValidateMinute((int)newValue);
                TimeSpan ts = new TimeSpan(value.Hour, (int)newValue, value.Second);
                value = value.Date + ts;
                break;
            }

            case TimeVariableType.Second:
            {
                TimeValidator.ValidateSecond((int)newValue);
                TimeSpan ts = new TimeSpan(value.Hour, value.Minute, (int)newValue);
                value = value.Date + ts;
                break;
            }
            }
        }
예제 #8
0
        public decimal GetTimeElement(string name, TimeVariableType type)
        {
            if (variables.Where(v => name.Equals(v.GetName())).Count() == 0)
            {
                return(0);
            }

            Named nv = variables.First(v => name.Equals(v.GetName()));

            if (nv is ITimeable)
            {
                return((nv as ITimeable).ToTimeVariable(type));
            }
            return(0);
        }
예제 #9
0
 public decimal ToTimeVariable(TimeVariableType type)
 {
     return(DateExtractor.GetVariable(ToTime(), type));
 }
예제 #10
0
 public TimeElementRefer(string name, TimeVariableType type)
 {
     this.name = name;
     this.type = type;
 }
예제 #11
0
 public TimeElementDeclaration(string name, TimeVariableType type, INumerable value)
 {
     this.name  = name;
     this.type  = type;
     this.value = value;
 }
예제 #12
0
 public Func__TimeBetween(ITimeable arg0, ITimeable arg1, TimeVariableType varType)
 {
     this.arg0    = arg0;
     this.arg1    = arg1;
     this.varType = varType;
 }