DateTimeExtensions icon indicating copy to clipboard operation
DateTimeExtensions copied to clipboard

Cstom

Open benrahn7 opened this issue 4 years ago • 2 comments

Hi, I am trying to use a custom cultureInfo class here. when I use this call var holidays = DateTime.UtcNow.AllYearHolidays(new CultureInfo()); I get An item with the same key has already been added. Key: 12/24/2021 12:00:00 AM"

I looked in the list of holidays but that doesn't exist. Am I missing something?

public class CultureInfo : WorkingDayCultureInfo { public CultureInfo() { //just return our custom Strategy LocateHolidayStrategy = (name, region) => new ArrtWorkingDayStrategy(); } } public class WorkingDayStrategy : EN_USHolidayStrategy {

    public WorkingDayStrategy()
    {
        this.InnerHolidays.Add(ChristianHolidays.ChristmasEve);
        this.InnerHolidays.Remove(ColumbusDay);
        this.InnerHolidays.Remove(NewYearsEve);
    }
}

benrahn7 avatar Jan 28 '21 21:01 benrahn7

Hi

I see you have there The ChristianHolidays.ChristmasEve. That is the 24th of December.

But you might still have that behavior because of special observances (holidays observed on different days), and that is only calculated on the fly when you request any holiday or list holidays for a certain year.

I'm doing some major overhaul on the insides, specifically for building observances more explicit, but I'm seriously lacking time (and motivation :D )

joaomatossilva avatar Jan 29 '21 21:01 joaomatossilva

12/28/2023 this was an unrecognized holiday it was a end of a cycle and we shifted into a new age

22AA3 avatar Mar 07 '24 12:03 22AA3