This project is a merge of several common DateTime operations on the form of extensions to System.DateTime, including natural date difference text (precise and
This project is a merge of several common DateTime operations on the form of extensions to System.DateTime, including natural date difference text (precise and
DateTimeExtensions is a powerful C# library that extends the functionality of System.DateTime and System.DateTimeOffset. It provides useful methods for working with dates and times, making your code more expressive and easier to read.
Install DateTimeExtensions via NuGet:
Install-Package DateTimeExtensionsHere are some examples of what you can do with DateTimeExtensions:
using DateTimeExtensions;
// Add 5 working days to a date
DateTime futureDate = DateTime.Now.AddWorkingDays(5);
// Check if a date is a working day
bool isWorkingDay = DateTime.Now.IsWorkingDay();
// Get the difference between dates in natural language
string dateDiff = DateTime.Now.ToNaturalText(DateTime.Now.AddDays(45));
// Check if a time is between two other times
bool isBetween = DateTime.Now.IsBetween(new Time("09:00"), new Time("17:00"));DateTimeExtensions supports working day and holiday calculations for many cultures, including:
Don't see your culture? Contributions are welcome!
You can export holidays to various calendar formats:
var exporter = ExportHolidayFormatLocator.LocateByType(ExportType.OfficeHolidays);
exporter.Export(new WorkingDayCultureInfo("en-US"), 2024, textWriter);Implement IWorkingDayCultureInfo to define custom working day rules for your specific needs.
We welcome contributions! Here's how you can help:
To add new holiday definitions, please prefix culture-specific holidays with the country name (e.g., "USA_IndependenceDay").
For more detailed information, visit our official documentation.
This project is licensed under the Apache License. See the LICENSE file for details.
DateTimeExtensions: Making date and time operations in C# simpler and more intuitive.
No open issues yet, or sync has not completed.