How joaomatossilva/datetimeextensions works
Main Components
• Library Core: This includes the primary assembly (located within src/DateTimeExtensions) that provides the extension methods (e.g., BusinessHoursExtensions, TimeExtensions, GeneralDateTimeExtensions).
• Working Days Module: Found under src/DateTimeExtensions/WorkingDays, this module handles holiday and working day calculations. It also includes culture-specific implementations (e.g., various HolidayStrategy classes in the CultureStrategies folder), interfaces like IHolidayStrategy and IWorkingDayCultureInfo, and helper classes like GlobalHolidays and DayInYear.
• Natural Text Module: Located in src/DateTimeExtensions/NaturalText, this module converts date differences into human-readable text. It uses a strategy pattern via interfaces such as INaturalTimeStrategy, along with various culture-specific strategies (like EN_GBNaturalTimeStrategy, FR_FRNaturalTimeStrategy, etc.).
• Export Module: Under src/DateTimeExtensions/Export, this component supports calendar export functionality. It provides mechanisms, such as via the ExportHolidayFormatLocator and IExportHolidaysFormat, to export holidays in different formats.
• Common Utilities: Components in src/DateTimeExtensions/Common (like DictionaryExtensions, ConcurrentLazyDictionary, and Locale-related classes) offer shared helper methods and abstractions that support the core library.
• Testing Suite: The tests directory contains comprehensive unit tests for all the features (covering business hours, working days, natural text, export functionalities, and culture-specific behaviors).
Relationships and Interactions
• The Core component is the entry point and integrates with all other modules. It exposes extension methods that internally call into the Working Days and Natural Text modules.
• The Working Days module provides strategies (using the Strategy pattern) to determine holidays and working days based on region-specific logic, interacting with the Common utilities for shared functionality.
• The Natural Text module retrieves the right culture-specific strategy to generate human-readable differences between dates.
• The Export module interacts with the Working Days module to retrieve holiday data which it then formats suitably.
• Testing components interact with all these modules to ensure that each function behaves as expected.
Architectural Patterns and Design Principles
• Modularity: The project separates the core functionality into distinct modules which encapsulate responsibilities (extensions, working days, natural text, export, and helpers).
• Strategy Pattern: Both the Natural Text and Working Days modules use the strategy pattern extensively, allowing different implementations per culture.
• Interface-Driven Design: Interfaces such as IExportHolidaysFormat, IHolidayStrategy, INaturalTimeStrategy, etc., decouple implementations from usage.
• Test-Driven: A dedicated tests suite ensures proper functionality; tests are organized per functional area and even for culture-specific behaviors.
Relevant Technologies, Frameworks, or Libraries
• .NET Framework / .NET Core (as implied by the use of C# and .csproj files).
• NuGet package management for distribution (as noted in the README).
• Source Link for debugging and transparency.
• GitHub Actions for CI/CD (.github/workflows/dotnet.yml).
• “Core API” sits at the center.
• “Core API” to three key modules: “Working Days”, “Natural Text”, and “Export”.
• Under “Natural Text”, show the variety of culture-specific time strategies.
• Link “Common Utilities” to both the “Working Days” and “Core API” modules.