Expand description
§Datetime Module - Zero-dependency datetime library for Minarrow
A lightweight, high-performance datetime library built specifically for Minarrow’s needs. Provides ISO8601/RFC3339 parsing, formatting, calendar operations, and business day calculations without external dependencies.
§Features
- Proleptic Gregorian calendar with epoch-based calculations
- ISO 8601 week numbering and custom week start configuration
- Calendar and fiscal quarters, half-years, years
- Business day calculations with configurable holidays
- Timezone offset support (UTC±HH:MM)
- Zero allocations for common operations
- SIMD-ready batch operations (TODO: parallelization)
§Design
All calculations use days-since-Unix-epoch (1970-01-01) as the fundamental unit, ensuring efficient arithmetic and consistent behavior across the library.
Structs§
- Calendar
Config - Calendar configuration for fiscal years, week starts, and holidays
- Date
Time Components - Date and time components.
- Time
Delta - Duration type for date/time arithmetic
Enums§
- Construct
Error - Construction errors
- Conversion
Error - Conversion errors
- Parse
Error - Parse errors
- Weekday
- Day of week enumeration
Functions§
- add_
business_ days - Add business days to a date
- add_
delta - Add a TimeDelta to a timestamp
- add_
months - Add months to a timestamp (calendar-aware)
- add_
years - Add years to a timestamp (calendar-aware)
- components_
to_ timestamp - Constructs a timestamp from date/time components.
- convert_
timestamp - Convert timestamp between time units
- count_
business_ days - Count business days in a date range (inclusive)
- day_
of_ week - Returns the day of week for a given date.
- day_
of_ year - Returns the day of year (1-366) for a given date.
- days_
in_ month - Returns the number of days in a given month, accounting for leap years.
- days_
to_ ymd - Converts days since Unix epoch to a civil date (year, month, day).
- diff_
timestamps - Calculate difference between two timestamps
- extract_
components - Extracts date and time components from a timestamp.
- first_
day_ of_ month - Get first day of month
- first_
day_ of_ quarter - Get first day of quarter
- first_
day_ of_ week - Get first day of week containing the given date
- first_
day_ of_ year - Get first day of year
- fiscal_
half_ year - Get fiscal half-year based on config
- fiscal_
quarter - Get fiscal quarter based on config
- fiscal_
year - Get fiscal year based on config
- format_
date_ only - Format timestamp as date only (YYYY-MM-DD)
- format_
iso8601 - Format timestamp as ISO8601 datetime string
- format_
rfc3339 - Format timestamp as RFC3339 datetime string (alias for ISO8601)
- format_
time_ only - Format timestamp as time only (HH:MM:SS)
- from_
timestamp_ millis - Construct timestamp from Unix timestamp in milliseconds
- from_
timestamp_ seconds - Construct timestamp from Unix timestamp in seconds
- from_
ymd - Construct timestamp from year, month, day (midnight UTC)
- from_
ymd_ hms - Construct timestamp from year, month, day, hour, minute, second
- from_
ymd_ hms_ nano - Construct timestamp from year, month, day, hour, minute, second, nanosecond
- half_
year - Get calendar half (1 or 2)
- is_
business_ day - Check if a date is a business day (not weekend, not holiday)
- is_
leap_ year - Checks if a year is a leap year in the proleptic Gregorian calendar.
- is_
weekend - Check if a date is a weekend
- last_
day_ of_ month - Get last day of month
- last_
day_ of_ quarter - Get last day of quarter
- last_
day_ of_ week - Get last day of week containing the given date
- last_
day_ of_ year - Get last day of year
- next_
business_ day - Get next business day after the given date
- parse_
datetime_ flexible - Parse datetime with flexible format detection
- parse_
iso8601 - Parse ISO8601 datetime string
- parse_
rfc3339 - Parse RFC3339 datetime string (alias for ISO8601)
- prev_
business_ day - Get previous business day before the given date
- quarter_
of_ year - Get calendar quarter (1-4)
- truncate_
to_ unit - Truncate timestamp to a coarser time unit
- week_
of_ month - Calculate week within the month
- week_
of_ year_ custom - Calculate week number with custom week start
- week_
of_ year_ iso - Calculate ISO 8601 week number
- ymd_
to_ days - Converts a civil date (year, month, day) to days since Unix epoch.