Expand description
§DateTime Module
This module defines a DateTime struct and helper functions for representing,
validating, and working with calendar date and time values in embedded systems.
§Features
- Stores year, month, day, hour, minute, second
- Built-in validation for all fields (including leap years and month lengths)
- Setter and getter methods that enforce validity
- Utility functions for leap year detection, days in a month, and weekday calculation
§Year Range
The default supported range is year >= 1970, which covers the widest set of popular RTC chips. For example:
- DS1307, DS3231: 2000-2099
Drivers are responsible for checking and enforcing the exact year range of the
underlying hardware. The DateTime type itself only enforces the lower bound (1970)
to remain reusable in contexts outside RTCs.
§Weekday Format
- This module uses 1=Sunday to 7=Saturday
- Drivers must handle conversion if required
Structs§
- Date
Time - Date and time representation used across RTC drivers.
Enums§
- Date
Time Error - Errors that can occur when working with DateTime
- Weekday
- Day of the week (1 = Sunday .. 7 = Saturday)
Functions§
- calculate_
weekday - Calculate the day of the week using Zeller’s congruence algorithm Returns 1=Sunday, 2=Monday, …, 7=Saturday
- days_
in_ month - Get the number of days in a month
- is_
leap_ year - Check if a year is a leap year