예제 #1
0
        public override DateTime ToTime()
        {
            int year = (int)arg0.ToNumber();

            TimeValidator.ValidateYear(year);

            return(Easter(year));
        }
예제 #2
0
        public override DateTime ToTime()
        {
            int year = (int)arg0.ToNumber();

            TimeValidator.ValidateYear(year);

            return(new DateTime(year, 1, 1, 0, 0, 0));
        }
예제 #3
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;
            }
            }
        }