예제 #1
0
        // ----------------------------------------------------------------------
        public TimeCalendar( TimeCalendarConfig config )
        {
            if ( config.StartOffset < TimeSpan.Zero )
            {
                throw new ArgumentOutOfRangeException( "config" );
            }
            if ( config.EndOffset > TimeSpan.Zero )
            {
                throw new ArgumentOutOfRangeException( "config" );
            }

            culture = config.Culture ?? Thread.CurrentThread.CurrentCulture;
            yearType = config.YearType.HasValue ? config.YearType.Value : YearType.SystemYear;
            startOffset = config.StartOffset.HasValue ? config.StartOffset.Value : DefaultStartOffset;
            endOffset = config.EndOffset.HasValue ? config.EndOffset.Value : DefaultEndOffset;
            yearBaseMonth = config.YearBaseMonth.HasValue ? config.YearBaseMonth.Value : TimeSpec.CalendarYearStartMonth;
            yearWeekType = config.YearWeekType.HasValue ? config.YearWeekType.Value : YearWeekType.Calendar;
            dayNameType = config.DayNameType.HasValue ? config.DayNameType.Value : CalendarNameType.Full;
            monthNameType = config.MonthNameType.HasValue ? config.MonthNameType.Value : CalendarNameType.Full;
        }
예제 #2
0
        public TimeCalendar(TimeCalendarConfig config)
        {
            if (config.StartOffset < TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException("config");
            }
            if (config.EndOffset > TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException("config");
            }

            Culture               = config.Culture ?? CultureInfo.CurrentCulture;
            YearType              = config.YearType.HasValue ? config.YearType.Value : YearType.SystemYear;
            StartOffset           = config.StartOffset.HasValue ? config.StartOffset.Value : DefaultStartOffset;
            EndOffset             = config.EndOffset.HasValue ? config.EndOffset.Value : DefaultEndOffset;
            YearBaseMonth         = config.YearBaseMonth.HasValue ? config.YearBaseMonth.Value : TimeSpec.CalendarYearStartMonth;
            FiscalYearBaseMonth   = config.FiscalYearBaseMonth.HasValue ? config.FiscalYearBaseMonth.Value : TimeSpec.FiscalYearBaseMonth;
            FiscalFirstDayOfYear  = config.FiscalFirstDayOfYear.HasValue ? config.FiscalFirstDayOfYear.Value : DayOfWeek.Sunday;
            FiscalYearAlignment   = config.FiscalYearAlignment.HasValue ? config.FiscalYearAlignment.Value : FiscalYearAlignment.None;
            FiscalQuarterGrouping = config.FiscalQuarterGrouping.HasValue ? config.FiscalQuarterGrouping.Value : FiscalQuarterGrouping.FourFourFiveWeeks;
            YearWeekType          = config.YearWeekType.HasValue ? config.YearWeekType.Value : YearWeekType.Calendar;
            _dayNameType          = config.DayNameType.HasValue ? config.DayNameType.Value : CalendarNameType.Full;
            _monthNameType        = config.MonthNameType.HasValue ? config.MonthNameType.Value : CalendarNameType.Full;
        }