Exemplo n.º 1
0
        public ExtendedDateTime(int year, int month = 1, int day = 1, int hour = 0, int minute = 0, int second = 0, int utcHourOffset = 0, int utcMinuteOffset = 0)
        {
            if (year < -9999 || year > 9999)
            {
                throw new ArgumentOutOfRangeException(nameof(year), year, $"The argument \"{nameof(year)}\" must be a value from -9999 to 9999");
            }

            if (month < 1 || month > 12)
            {
                throw new ArgumentOutOfRangeException(nameof(month), month, $"The argument \"{nameof(month)}\" must be a value from 1 to 12");
            }

            if (day < 1 || day > ExtendedDateTimeCalculator.DaysInMonth(year, month))
            {
                throw new ArgumentOutOfRangeException(nameof(day), day, $"The argument \"{nameof(day)}\" must be a value from 1 to {ExtendedDateTimeCalculator.DaysInMonth(year, month)}");
            }

            if (hour < 0 || hour > 23)
            {
                throw new ArgumentOutOfRangeException(nameof(hour), hour, $"The argument \"{nameof(hour)}\" must be a value from 0 to 23");
            }

            if (minute < 0 || minute > 59)
            {
                throw new ArgumentOutOfRangeException(nameof(minute), minute, $"The argument \"{nameof(minute)}\" must be a value from 0 to 59");
            }

            if (second < 0 || second > 59)
            {
                throw new ArgumentOutOfRangeException(nameof(second), second, $"The argument \"{nameof(second)}\" must be a value from 0 to 59");
            }

            _year      = year;
            _month     = month;
            _day       = day;
            _hour      = hour;
            _minute    = minute;
            _second    = second;
            _utcOffset = new TimeSpan(utcHourOffset, utcMinuteOffset, 0);
        }
Exemplo n.º 2
0
 public ExtendedDateTime ToRoundedPrecision(ExtendedDateTimePrecision p, bool roundUp = false)
 {
     return(ExtendedDateTimeCalculator.ToRoundedPrecision(this, p, roundUp));
 }
Exemplo n.º 3
0
 public ExtendedDateTime SubtractYears(int count)
 {
     return(ExtendedDateTimeCalculator.SubtractYears(this, count));
 }
Exemplo n.º 4
0
 public ExtendedDateTime AddYears(int count)
 {
     return(ExtendedDateTimeCalculator.AddYears(this, count));
 }
Exemplo n.º 5
0
 public ExtendedDateTime AddMonths(int count, DayExceedsDaysInMonthStrategy dayExceedsDaysInMonthStrategy = DayExceedsDaysInMonthStrategy.RoundDown)
 {
     return(ExtendedDateTimeCalculator.AddMonths(this, count, dayExceedsDaysInMonthStrategy));
 }
Exemplo n.º 6
0
 public static ExtendedDateTime operator +(ExtendedDateTime e, TimeSpan t)
 {
     return(ExtendedDateTimeCalculator.Add(e, t));
 }
Exemplo n.º 7
0
 public static TimeSpan operator -(ExtendedDateTime e2, ExtendedDateTime e1)
 {
     return(ExtendedDateTimeCalculator.Subtract(e2, e1));
 }
Exemplo n.º 8
0
 public static ExtendedDateTime operator -(ExtendedDateTime e, TimeSpan t)
 {
     return(ExtendedDateTimeCalculator.Subtract(e, t));
 }