Chrononuensis is a library for parsing complex time periods like year-month, year-quarter, month-week, and year-week. Effortlessly decode and validate non-standard formats, handle fiscal calendars, ordinal days, and custom cycles. Lightweight, flexible, and precise, it structures time data with 8000 ease.
About | Installing | Quickstart
Continuous integration builds:
Creating a new reference using .NET CLI If you’re using the .NET command-line interface (CLI), open a terminal in your project’s root directory and run:
dotnet add package Chrononuensis
This will:
- Add the Chrononuensis package to your project.
- Update the csproj file to include it as a dependency.
Structs in Chrononuensis are lightweight data structures designed to hold parsed data. They are optimized for performance and memory efficiency. They are immutable where possible, ensuring data integrity.
You can create a struct directly by passing its required values to the constructor.
Chrononuensis follows a consistent parameter ordering for struct constructors and parsers. This order follows a decreasing specificity pattern, similar to how DateTime works in .NET. i.e. for the YearMonth struct, Year comes before Month, following a logical decreasing order.
// Create a Year-Month period for July 2025
var yearMonth = new YearMonth(2025, 7);
Instead of manually creating a struct, you can parse a formatted string to obtain a struct.
If you have a formatted string “2025-08” and want to convert it into a YearMonth struct, use the Parse method:
// Parse a period Year-Month for August 2025
var other = YearMonth.Parse("2025-08", "yyyy-MM");
In this example,
2025-08
is the input string.yyyy-MM
is the format that defines how the input should be interpreted.
The parser extracts year and month from the string and returns a YearMonth struct.
Parsers in Chrononuensis are flexible tools that extract structured information from input strings. Their role is not to instantiate predefined structs or classes, but rather to return extracted components (as integers) so that you can use them to create your own structures.
Instead of returning a predefined struct, a parser simply extracts and returns individual components. For example, given an input string like "2025-08":
var parser = new YearMonthParser();
(int year, int month) = parser.Parse("2025-08", "yyyy-MM");
Chrononuensis provides a set of predefined structures for parsing and representing date-based information.
- MonthDay
- YearDay
- YearWeek
- YearMonth
- YearQuarter
- YearSemester
- Year: yy and yyyy
- Semester: S
- Quarter: q
- Month: M, MM, MMM, MMMM
- Week: w, ww
- Day of Year: j and jjj
- Day: d, dd