public bool EqualsModel(DynamicCalendarModel model) { int i = 0; int iMonth = 1; foreach (var m in model.Months) { if (i >= FullNames.Length) { i = 0; } try { if (m.FullName != FullNames[i].Replace("%M", iMonth.ToString()) || m.ShortName != ShortNames[i].Replace("%M", iMonth.ToString())) { return(false); } } catch { } i++; iMonth++; } return(true); }
public void CopyToModel(DynamicCalendarModel model) { if (!OnlyUserAction) { int i = 0; int iMonth = 1; foreach (var m in model.Months) { if (i >= FullNames.Length) { i = 0; } try { m.FullName = FullNames[i].Replace("%M", iMonth.ToString()); m.ShortName = ShortNames[i].Replace("%M", iMonth.ToString()); } catch { } i++; iMonth++; } } UserAction?.Invoke(model); }
public static DynamicDateFormatInfo GetInstance(string calendarModelId, IFormatProvider provider = null) { if (provider == null) { provider = CultureInfo.CurrentCulture; } string cInfId = calendarModelId + "_" + provider.ToString(); if (infoCacheS.ContainsKey(cInfId)) { return(infoCacheS[cInfId]); } DateTimeFormatInfo x = DateTimeFormatInfo.GetInstance(provider); var inf = new DynamicDateFormatInfo(x); if (string.IsNullOrEmpty(calendarModelId)) { return((DynamicDateFormatInfo)inf.Clone()); } var model = DynamicCalendarModel.GetCachedModel(calendarModelId); if (model != null && model.FormatInfo != null) { inf.CalendarModelID = calendarModelId; var mi = model.FormatInfo; inf.Import(mi); } return(inf); }
public bool EqualsModel(DynamicCalendarModel model) { return(model.CommonYearLength.Equals(CommonYearLength) && model.FirstMonthFirstDayType == FirstMonthFirstDayType && model.YearLengthAssignment == YearLengthAssignment && model.YearLengthAssigBeforeMonth == YearLengthAssigBeforeMonth && model.LeapModel.Equals(LeapModel)); }
public TimeSpan GetMaxOffset(DynamicCalendarModel model) { if (!_maxValue.HasValue) { ResyncMax(model); if (AddOnOffset != null) { _maxValue += AddOnOffset.GetMaxOffset(model); } } return(_maxValue.Value); }
public TimeSpan GetOffset(DateTime tStart, DynamicCalendarModel model, int nOffsetDays = 0) { //if (!_value.HasValue) { Resync(tStart, model, nOffsetDays); if (AddOnOffset != null) { _value += AddOnOffset.GetOffset(tStart + _value.Value, model); } } return(_value.Value); }
static void AddCommonMonthName(DynamicCalendarModel model, int commonMonthNr, int monthNr, int monthLength, List <MonthDay> days = null) { DateTime t = new DateTime(2000, commonMonthNr, 1); var m = new Month() { Number = monthNr, Length = new TimeOffsetStatic(monthLength), FullName = t.ToString("MMMM"), ShortName = t.ToString("MMM") }; if (days != null && days.Count > 0) { m.Days = days; } model.Months.Add(m); }
public void CopyToModel(DynamicCalendarModel model) { if (!OnlyUserAction) { int iStartYearNumberDiff = 0; if (model.ModelStartPoint != null) { iStartYearNumberDiff = model.ModelStartPoint.GetTimePoint(model).Year - model.ModelStartYearNumber; } if (CommonYearLength.HasAstronomics) { model.ModelStartPoint = new TimePoint { StartDate = new DateTime(DateTime.Now.Year - 1, 3, 1), Offset = sys.CloneObject(CommonYearLength) } } ; else if (CommonYearLength is TimeOffsetGregorianDate) { model.ModelStartPoint = new TimePoint { StartDate = new DateTime(DateTime.Now.Year - 1, 3, 1), Offset = sys.CloneObject(CommonYearLength) } } ; else { model.ModelStartPoint = new TimePoint { StartDate = new DateTime(DateTime.Now.Year, 1, 1), Offset = null } }; model.ModelStartYearNumber = model.ModelStartPoint.GetTimePoint(model).Year - iStartYearNumberDiff; model.CommonYearLength = sys.CloneObject(CommonYearLength); model.FirstMonthFirstDayType = FirstMonthFirstDayType; model.YearLengthAssignment = YearLengthAssignment; model.YearLengthAssigBeforeMonth = YearLengthAssigBeforeMonth; model.LeapModel = sys.CloneObject(LeapModel); } UserAction?.Invoke(model); model.ClearCache(); }
protected abstract void ResyncMax(DynamicCalendarModel model);
protected abstract void Resync(DateTime tStart, DynamicCalendarModel model, int nOffsetDays = 0);
public int GetMaxOffsetDays(DynamicCalendarModel model) { double nDays = GetMaxOffset(model).TotalDays; return((int)Math.Ceiling(nDays)); }
public int GetOffsetDays(DateTime tStart, DynamicCalendarModel model, int nOffsetDays = 0) { double nDays = GetOffset(tStart, model, nOffsetDays).TotalDays; return((int)Math.Ceiling(nDays)); }
public DateTime GetTimePoint(DynamicCalendarModel model) { return(StartDate + (Offset == null ? TimeSpan.FromTicks(0) : TimeSpan.FromDays(Offset.GetOffsetDays(StartDate, model)))); }
public static DynamicCalendarModel CreateModel(CalendarModelSample sample) { var Model = new DynamicCalendarModel(); Model.Name = "my" + sample.ToString(); Model.ID = sample.ToString() + "_" + Guid.NewGuid().ToString(); Model.BaseSample = sample.ToString(); int iSameName = 0; if (CalendarModelCfgHolder.LastModelCfgList != null) { foreach (var s in CalendarModelCfgHolder.LastModelCfgList.Values) { if (s.Name.StartsWith(Model.Name)) { iSameName++; } } } if (iSameName > 0) { Model.Name += " " + (iSameName + 1).ToString(); } int iNowYear = DateTime.Now.Year; var to28 = new TimeOffsetStatic(28); switch (sample) { case CalendarModelSample.Gregorian: Model.ModelStartPoint = new TimePoint(new DateTime(iNowYear, 01, 01)); Model.ModelStartYearNumber = iNowYear; AddCommonMonthName(Model, 1, 1, 31); AddCommonMonthName(Model, 2, 2, 28); AddCommonMonthName(Model, 3, 3, 31); AddCommonMonthName(Model, 4, 4, 30); AddCommonMonthName(Model, 5, 5, 31); AddCommonMonthName(Model, 6, 6, 30); AddCommonMonthName(Model, 7, 7, 31); AddCommonMonthName(Model, 8, 8, 31); AddCommonMonthName(Model, 9, 9, 30); AddCommonMonthName(Model, 10, 10, 31); AddCommonMonthName(Model, 11, 11, 30); AddCommonMonthName(Model, 12, 12, 31); YearLengthSampleS[CalendarModelSample.Gregorian.ToString()].CopyToModel(Model); break; case CalendarModelSample.InternationalFixed: Model.ModelStartPoint = new TimePoint(new DateTime(iNowYear, 01, 01)); Model.ModelStartYearNumber = iNowYear; Model.MonthWeekStartType = WeekStartType.FristDayIsFirstWeekDay; AddCommonMonthName(Model, 1, 1, 28); AddCommonMonthName(Model, 2, 2, 28); AddCommonMonthName(Model, 3, 3, 28); AddCommonMonthName(Model, 4, 4, 28); AddCommonMonthName(Model, 5, 5, 28); AddCommonMonthName(Model, 6, 6, 28); Model.Months.Add(new Month() { Number = 7, Length = to28, FullName = "Sol", ShortName = "Sol" }); AddCommonMonthName(Model, 7, 8, 28); AddCommonMonthName(Model, 8, 9, 28); AddCommonMonthName(Model, 9, 10, 28); AddCommonMonthName(Model, 10, 11, 28); AddCommonMonthName(Model, 11, 12, 28); AddCommonMonthName(Model, 12, 13, 28); YearLengthSampleS[CalendarModelSample.Gregorian.ToString()].CopyToModel(Model); Model.YearLengthAssignment = ExtraDaysAssignment.OutOfTime; Model.ContinueWeeksOutOfTime = false; Model.YearLengthAssigBeforeMonth = -1; Model.LeapModel.LeapBeforeMonth = 6; Model.LeapModel.DaysAssignment = ExtraDaysAssignment.OutOfTime; break; case CalendarModelSample.NewEarth: Model.ModelStartPoint = new TimePoint(new DateTime(iNowYear, 01, 01)); Model.ModelStartYearNumber = iNowYear; Model.MonthWeekStartType = WeekStartType.FristDayIsFirstWeekDay; AddCommonMonthName(Model, 1, 1, 28); AddCommonMonthName(Model, 2, 2, 28); AddCommonMonthName(Model, 3, 3, 28); AddCommonMonthName(Model, 4, 4, 28); AddCommonMonthName(Model, 5, 5, 28); AddCommonMonthName(Model, 6, 6, 28); Model.Months.Add(new Month() { Number = 7, Length = to28, FullName = "Luna", ShortName = "Lun" }); AddCommonMonthName(Model, 7, 8, 28); AddCommonMonthName(Model, 8, 9, 28); AddCommonMonthName(Model, 9, 10, 28); AddCommonMonthName(Model, 10, 11, 28); AddCommonMonthName(Model, 11, 12, 28); AddCommonMonthName(Model, 12, 13, 28); YearLengthSampleS[CalendarModelSample.NewEarth.ToString()].CopyToModel(Model); break; case CalendarModelSample.MenstrualCycle: Model.ModelStartPoint = new TimePoint(new DateTime(iNowYear, 01, 01)); Model.ModelStartYearNumber = iNowYear; Model.MonthsTitle = "Zyklus"; Model.Months.Add(new Month() { Number = 1, Length = to28, FullName = Model.MonthsTitle + " 1", EndType = MonthEndType.ManualEndOrOpen }); Model.Months.Add(new Month() { Number = 2, Length = to28, FullName = Model.MonthsTitle + " 2", EndType = MonthEndType.ManualEndOrOpen }); Model.Months.Add(new Month() { Number = 3, Length = to28, FullName = Model.MonthsTitle + " 3", EndType = MonthEndType.ManualEndOrOpen }); Model.Months.Add(new Month() { Number = 4, Length = to28, FullName = Model.MonthsTitle + " 4", EndType = MonthEndType.ManualEndOrOpen }); Model.Months.Add(new Month() { Number = 5, Length = to28, FullName = Model.MonthsTitle + " 5", EndType = MonthEndType.ManualEndOrOpen }); Model.Months.Add(new Month() { Number = 6, Length = to28, FullName = Model.MonthsTitle + " 6", EndType = MonthEndType.ManualEndOrOpen }); Model.Months.Add(new Month() { Number = 7, Length = to28, FullName = Model.MonthsTitle + " 7", EndType = MonthEndType.ManualEndOrOpen }); Model.Months.Add(new Month() { Number = 8, Length = to28, FullName = Model.MonthsTitle + " 8", EndType = MonthEndType.ManualEndOrOpen }); Model.Months.Add(new Month() { Number = 9, Length = to28, FullName = Model.MonthsTitle + " 9", EndType = MonthEndType.ManualEndOrOpen }); Model.Months.Add(new Month() { Number = 10, Length = to28, FullName = Model.MonthsTitle + " 10", EndType = MonthEndType.ManualEndOrOpen }); Model.Months.Add(new Month() { Number = 11, Length = to28, FullName = Model.MonthsTitle + " 11", EndType = MonthEndType.ManualEndOrOpen }); Model.Months.Add(new Month() { Number = 12, Length = to28, FullName = Model.MonthsTitle + " 12", EndType = MonthEndType.ManualEndOrOpen }); Model.Months.Add(new Month() { Number = 13, Length = to28, FullName = Model.MonthsTitle + " 13", EndType = MonthEndType.ManualEndOrOpen }); Model.Months.Add(new Month() { Number = 14, Length = to28, FullName = Model.MonthsTitle + " 14", EndType = MonthEndType.ManualEndOrOpen }); Model.Months.Add(new Month() { Number = 15, Length = to28, FullName = Model.MonthsTitle + " 15", EndType = MonthEndType.ManualEndOrOpen }); YearLengthSampleS[CalendarModelSample.Gregorian.ToString()].CopyToModel(Model); Model.FirstMonthFirstDayType = FirstMonthFirstDayType.ContinueLastYear; Model.LeapModel.DaysAssignment = ExtraDaysAssignment.None; break; case CalendarModelSample.MoonCalendar: var toFullMoon = new TimeOffsetAstronomic { OrbName = "Moon", OrbMember = OrbMember.PhaseNumber, Direction = Direction.Forward, PointType = AstroPointType.UpperPeak }; Model.ModelStartPoint = new TimePoint(new DateTime(iNowYear, 01, 01)); Model.ModelStartYearNumber = iNowYear; Model.MonthsTitle = "Moon"; Model.Months.Add(new Month() { Number = 1, Length = toFullMoon, FullName = Model.MonthsTitle + " 1", ShortName = "M1" }); Model.Months.Add(new Month() { Number = 2, Length = toFullMoon, FullName = Model.MonthsTitle + " 2", ShortName = "M2" }); Model.Months.Add(new Month() { Number = 3, Length = toFullMoon, FullName = Model.MonthsTitle + " 3", ShortName = "M3" }); Model.Months.Add(new Month() { Number = 4, Length = toFullMoon, FullName = Model.MonthsTitle + " 4", ShortName = "M4" }); Model.Months.Add(new Month() { Number = 5, Length = toFullMoon, FullName = Model.MonthsTitle + " 5", ShortName = "M5" }); Model.Months.Add(new Month() { Number = 6, Length = toFullMoon, FullName = Model.MonthsTitle + " 6", ShortName = "M6" }); Model.Months.Add(new Month() { Number = 7, Length = toFullMoon, FullName = Model.MonthsTitle + " 7", ShortName = "M7" }); Model.Months.Add(new Month() { Number = 8, Length = toFullMoon, FullName = Model.MonthsTitle + " 8", ShortName = "M8" }); Model.Months.Add(new Month() { Number = 9, Length = toFullMoon, FullName = Model.MonthsTitle + " 9", ShortName = "M9" }); Model.Months.Add(new Month() { Number = 10, Length = toFullMoon, FullName = Model.MonthsTitle + " 10", ShortName = "M10" }); Model.Months.Add(new Month() { Number = 11, Length = toFullMoon, FullName = Model.MonthsTitle + " 11", ShortName = "M11" }); Model.Months.Add(new Month() { Number = 12, Length = toFullMoon, FullName = Model.MonthsTitle + " 12", ShortName = "M12" }); Model.Months.Add(new Month() { Number = 13, Length = toFullMoon, FullName = Model.MonthsTitle + " 13", ShortName = "M13" }); Model.Months.Add(new Month() { Number = 14, Length = toFullMoon, FullName = Model.MonthsTitle + " 14", ShortName = "M14" }); YearLengthSampleS[CalendarModelSample.Gregorian.ToString()].CopyToModel(Model); Model.FirstMonthFirstDayType = FirstMonthFirstDayType.ContinueLastYear; Model.LeapModel.DaysAssignment = ExtraDaysAssignment.None; break; case CalendarModelSample.SolarSeasons: Model.ModelStartPoint = new TimePoint(new DateTime(iNowYear, 01, 01), new TimeOffsetAstronomic { OrbName = "Sun", OrbMember = OrbMember.RA, PointType = AstroPointType.LowerPeak }); Model.ModelStartYearNumber = iNowYear; Model.Months.Add(new Month() { Number = 1, Length = new TimeOffsetAstronomic { OrbName = "Sun", OrbMember = OrbMember.RA, PointType = AstroPointType.DestinationPoint, DestinationValue = 6 }, FullName = "Frühling", ShortName = "Frü" }); Model.Months.Add(new Month() { Number = 2, Length = new TimeOffsetAstronomic { OrbName = "Sun", OrbMember = OrbMember.RA, PointType = AstroPointType.DestinationPoint, DestinationValue = 12 }, FullName = "Sommer", ShortName = "Som" }); Model.Months.Add(new Month() { Number = 3, Length = new TimeOffsetAstronomic { OrbName = "Sun", OrbMember = OrbMember.RA, PointType = AstroPointType.DestinationPoint, DestinationValue = 18 }, FullName = "Herbst", ShortName = "Her" }); Model.Months.Add(new Month() { Number = 4, Length = new TimeOffsetAstronomic { OrbName = "Sun", OrbMember = OrbMember.RA, PointType = AstroPointType.LowerPeak }, FullName = "Winter", ShortName = "Win" }); Model.LeapModel.DaysAssignment = ExtraDaysAssignment.None; Model.CommonYearLength = new TimeOffsetAstronomic { OrbName = "Sun", OrbMember = OrbMember.RA, PointType = AstroPointType.LowerPeak }; Model.LeapModel = new LeapModel(); break; case CalendarModelSample.WorldSeasons: Model.ModelStartPoint = new TimePoint(new DateTime(iNowYear - 1, 12, 21)); Model.ModelStartYearNumber = iNowYear; Model.Months.Add(new Month() { Number = 1, Length = new TimeOffsetStatic(91), FullName = "Winter", ShortName = "Win" }); Model.Months.Add(new Month() { Number = 2, Length = new TimeOffsetStatic(91), FullName = "Frühling", ShortName = "Frü" }); Model.Months.Add(new Month() { Number = 3, Length = new TimeOffsetStatic(91), FullName = "Sommer", ShortName = "Som" }); Model.Months.Add(new Month() { Number = 4, Length = new TimeOffsetStatic(91), FullName = "Herbst", ShortName = "Her" }); Model.CommonYearLength = new TimeOffsetStatic(365); Model.LeapModel = new LeapModel(); Model.LeapModel.ConditionType = LeapConditionType.Algorithm; Model.LeapModel.LeapOffset = new TimeOffsetStatic(1); Model.LeapModel.LeapBeforeMonth = 2; Model.LeapModel.DaysAssignment = ExtraDaysAssignment.AttachToMonth; Model.LeapModel.LeapYearAlgo.Add(new LeapYearAlgoCfg() { Dividor = 4, IsLeap = true }); Model.LeapModel.LeapYearAlgo.Add(new LeapYearAlgoCfg() { Dividor = 100, IsLeap = false }); Model.LeapModel.LeapYearAlgo.Add(new LeapYearAlgoCfg() { Dividor = 400, IsLeap = true }); break; case CalendarModelSample.MayaHaab: var to20 = new TimeOffsetStatic(20); Model.ModelStartPoint = new TimePoint(new DateTime(2012, 4, 4)); Model.ModelStartYearNumber = 1; Model.MayaCorrelation = MayaCalc.DefaultMayaCorrelation; Model.FormatInfo.ShortYearPattern = "&MayaDate&"; Model.FormatInfo.MiddleYearPattern = "&MayaDate&"; Model.FormatInfo.LongYearPattern = "&MayaDate&"; Model.FormatInfo.ShortMonthDayPattern = "&MayaDateHaab&"; Model.FormatInfo.MiddleMonthDayPattern = "&MayaDateHaab&"; Model.FormatInfo.LongMonthDayPattern = "&MayaDateHaab&"; Model.FormatInfo.ShortYearMonthPattern = "&MayaDateTzolkin& &MayaDateHaab&"; Model.FormatInfo.MiddleYearMonthPattern = "&MayaDateTzolkin& &MayaDateHaab&"; Model.FormatInfo.LongYearMonthPattern = "&MayaDateTzolkin& &MayaDateHaab&"; Model.FormatInfo.ShortDatePattern = "&MayaDateTzolkin& &MayaDateHaab&"; Model.FormatInfo.MiddleDatePattern = "&MayaDateTzolkin& &MayaDateHaab&"; Model.FormatInfo.LongDatePattern = "&MayaDate&, &MayaDateTzolkin& &MayaDateHaab&"; Model.FormatInfo.LongDayPattern = "'Kin' &MayaHaabKin&"; Model.FormatInfo.LongWeekDayDayPattern = "dddd, &MayaDateHaab&"; Model.FormatInfo.OverrideMaxYearDigits = 2; Model.Months.Add(new Month() { Number = 1, Length = to20, FullName = "Pop", ShortName = "Pop", DayNumberType = DayNumberType.ZeroBased }); Model.Months.Add(new Month() { Number = 2, Length = to20, FullName = "Uo", ShortName = "Uo", DayNumberType = DayNumberType.ZeroBased }); Model.Months.Add(new Month() { Number = 3, Length = to20, FullName = "Zip", ShortName = "Zip", DayNumberType = DayNumberType.ZeroBased }); Model.Months.Add(new Month() { Number = 4, Length = to20, FullName = "Zotz", ShortName = "Zotz", DayNumberType = DayNumberType.ZeroBased }); Model.Months.Add(new Month() { Number = 5, Length = to20, FullName = "Zec", ShortName = "Zec", DayNumberType = DayNumberType.ZeroBased }); Model.Months.Add(new Month() { Number = 6, Length = to20, FullName = "Xul", ShortName = "Xul", DayNumberType = DayNumberType.ZeroBased }); Model.Months.Add(new Month() { Number = 7, Length = to20, FullName = "Yaxkin", ShortName = "Yaxkin", DayNumberType = DayNumberType.ZeroBased }); Model.Months.Add(new Month() { Number = 8, Length = to20, FullName = "Mol", ShortName = "Mol", DayNumberType = DayNumberType.ZeroBased }); Model.Months.Add(new Month() { Number = 9, Length = to20, FullName = "Chen", ShortName = "Chen", DayNumberType = DayNumberType.ZeroBased }); Model.Months.Add(new Month() { Number = 10, Length = to20, FullName = "Yax", ShortName = "Yax", DayNumberType = DayNumberType.ZeroBased }); Model.Months.Add(new Month() { Number = 11, Length = to20, FullName = "Zac", ShortName = "Zac", DayNumberType = DayNumberType.ZeroBased }); Model.Months.Add(new Month() { Number = 12, Length = to20, FullName = "Ceh", ShortName = "Ceh", DayNumberType = DayNumberType.ZeroBased }); Model.Months.Add(new Month() { Number = 13, Length = to20, FullName = "Mac", ShortName = "Mac", DayNumberType = DayNumberType.ZeroBased }); Model.Months.Add(new Month() { Number = 14, Length = to20, FullName = "Kankin", ShortName = "Kankin", DayNumberType = DayNumberType.ZeroBased }); Model.Months.Add(new Month() { Number = 15, Length = to20, FullName = "Muan", ShortName = "Muan", DayNumberType = DayNumberType.ZeroBased }); Model.Months.Add(new Month() { Number = 16, Length = to20, FullName = "Pax", ShortName = "Pax", DayNumberType = DayNumberType.ZeroBased }); Model.Months.Add(new Month() { Number = 17, Length = to20, FullName = "Kayab", ShortName = "Kayab", DayNumberType = DayNumberType.ZeroBased }); Model.Months.Add(new Month() { Number = 18, Length = to20, FullName = "Cumku", ShortName = "Cumku", DayNumberType = DayNumberType.ZeroBased }); Model.Months.Add(new Month() { Number = 19, Length = new TimeOffsetStatic(5), FullName = "Wayeb", ShortName = "Wayeb", DayNumberType = DayNumberType.ZeroBased }); Model.CommonYearLength = new TimeOffsetStatic(365); Model.LeapModel = new LeapModel(); break; case CalendarModelSample.SexagesimalCalendar: var to1 = new TimeOffsetStatic(1); var to60 = new TimeOffsetStatic(60); Model.ModelStartPoint = new TimePoint(new DateTime(2012, 12, 21)); Model.ModelStartYearNumber = 1; Model.WeekLength = 6; Model.MonthWeekStartType = WeekStartType.FristDayIsFirstWeekDay; Model.Months.Add(new Month() { Number = 1, Length = to60, FullName = "Frigée", ShortName = "Fri" }); Model.OutOfTimeSections.Add(new OutOfTimeSection { BeforeMonth = 1, Length = to1, FullName = "Bacchanal" }); Model.Months.Add(new Month() { Number = 2, Length = to60, FullName = "Éclose", ShortName = "Écl" }); Model.OutOfTimeSections.Add(new OutOfTimeSection { BeforeMonth = 2, Length = to1, FullName = "Ceres" }); Model.Months.Add(new Month() { Number = 3, Length = to60, FullName = "Florée", ShortName = "Flo" }); Model.OutOfTimeSections.Add(new OutOfTimeSection { BeforeMonth = 3, Length = to1, FullName = "Musica" }); Model.Months.Add(new Month() { Number = 4, Length = to60, FullName = "Granée", ShortName = "Gra" }); Model.OutOfTimeSections.Add(new OutOfTimeSection { BeforeMonth = 4, Length = to1, FullName = "Liber" }); Model.Months.Add(new Month() { Number = 5, Length = to60, FullName = "Récole", ShortName = "Réc" }); Model.OutOfTimeSections.Add(new OutOfTimeSection { BeforeMonth = 5, Length = to1, FullName = "Memento mori" }); Model.Months.Add(new Month() { Number = 6, Length = to60, FullName = "Caduce", ShortName = "Cad" }); Model.OutOfTimeSections.Add(new OutOfTimeSection { BeforeMonth = 6, Length = to1, FullName = "Sext" }); Model.CommonYearLength = new TimeOffsetStatic(365); Model.LeapModel = new LeapModel(); Model.LeapModel.ConditionType = LeapConditionType.Algorithm; Model.LeapModel.LeapOffset = new TimeOffsetStatic(1); Model.LeapModel.DaysAssignment = ExtraDaysAssignment.None; Model.LeapModel.LeapYearAlgo.Add(new LeapYearAlgoCfg() { Dividor = 4, IsLeap = true }); Model.LeapModel.LeapYearAlgo.Add(new LeapYearAlgoCfg() { Dividor = 100, IsLeap = false }); Model.LeapModel.LeapYearAlgo.Add(new LeapYearAlgoCfg() { Dividor = 400, IsLeap = true }); Model.FormatInfo.OverrideMaxYearDigits = 3; break; } DynamicCalendarModel.AddCachedModel(Model); return(Model); }
public DynamicDate(DynamicCalendarModel mModel, int iYear, int iMonth, int iDay, DateTime?tUtcDate = null) { HasData = true; ModelID = mModel.ID; Year = iYear; Month = iMonth; Day = iDay; while (Month < 0) { Month += mModel.GetMonthsOfYear(Year - 1); //Tage zählen!! auch bei +!! Year--; } while (Day < 0) { Day += Month > 0 ? mModel.GetDaysOfMonth(Year, Month - 1) + mModel.GetOutOfTimeDays(Year, Month - 1) : mModel.GetDaysOfMonth(Year - 1, mModel.GetMonthsOfYear(Year - 1) - 1) + mModel.GetOutOfTimeDays(Year - 1, mModel.GetMonthsOfYear(Year - 1) - 1) + mModel.GetOutOfTimeDays(Year - 1, mModel.GetMonthsOfYear(Year - 1)); Month--; while (Month < 0) { Month += mModel.GetMonthsOfYear(Year - 1); Year--; } } while (Month > mModel.GetMonthsOfYear(Year) || (Month == mModel.GetMonthsOfYear(Year) && Day >= mModel.GetOutOfTimeDays(Year, Month))) { if (Month == mModel.GetMonthsOfYear(Year)) { Day -= mModel.GetOutOfTimeDays(Year, Month); } Month -= mModel.GetMonthsOfYear(Year); Year++; } while (Day >= mModel.GetDaysOfMonth(Year, Month) + mModel.GetOutOfTimeDays(Year, Month)) { Day -= mModel.GetDaysOfMonth(Year, Month) + mModel.GetOutOfTimeDays(Year, Month); Month++; while (Month > mModel.GetMonthsOfYear(Year) || (Month == mModel.GetMonthsOfYear(Year) && Day >= mModel.GetOutOfTimeDays(Year, Month))) { if (Month == mModel.GetMonthsOfYear(Year)) { Day -= mModel.GetOutOfTimeDays(Year, Month); } Month -= mModel.GetMonthsOfYear(Year); Year++; } } _dayOfWeek = null; if (tUtcDate != null) { _utcYear = tUtcDate.Value.Year; _utcDayOfYear = tUtcDate.Value.DayOfYear; } else { _utcYear = -1; _utcDayOfYear = -1; } }