Beispiel #1
0
        public string GetFrontMonth(DateTime date, bool useExpiryRatherThanRoll = false)
        {
            var d          = date.AddMonths(-_settings.RollGen.MonthModifier);
            var trialMonth = s_futureMonths[d.Month - 1];
            var trialYear  = d.Year > YearBeforeWhich2DigitDatesAreUsed?DateExtensions.SingleDigitYear(d.Year) : DateExtensions.DoubleDigitYear(d.Year);

            var trialCodeString = $"{Prefix}{trialMonth}{trialYear}";
            var trialCode       = new FutureCode(trialCodeString, YearBeforeWhich2DigitDatesAreUsed, _futureSettingsProvider);

            trialCodeString = trialCode.GetPreviousCode();
            trialCode       = new FutureCode(trialCodeString, YearBeforeWhich2DigitDatesAreUsed, _futureSettingsProvider);
            trialCodeString = trialCode.GetNextCode(false);
            trialCode       = new FutureCode(trialCodeString, YearBeforeWhich2DigitDatesAreUsed, _futureSettingsProvider);

            var testDate = useExpiryRatherThanRoll ? trialCode.GetExpiry() : trialCode.GetRollDate();

            if (testDate < date)
            {
                trialCodeString = trialCode.GetNextCode(false);
            }

            return(trialCodeString);
        }
Beispiel #2
0
        public static DateTime GetRollFromCode(string code, IFutureSettingsProvider futureSettingsProvider)
        {
            var c = new FutureCode(code, DateTime.Today.Year - 2, futureSettingsProvider);

            return(c.GetRollDate());
        }