Crate spacecell

Crate spacecell 

Source
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§

CalendarConfig
Calendar configuration for fiscal years, week starts, and holidays
DateTimeComponents
Date and time components.
TimeDelta
Duration type for date/time arithmetic

Enums§

ConstructError
Construction errors
ConversionError
Conversion errors
ParseError
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.