Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
ah-date.H File Reference

Lightweight helpers for validating and formatting civil dates. More...

#include <array>
#include <ctime>
#include <limits>
#include <string>
#include <ah-errors.H>
Include dependency graph for ah-date.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  Aleph
 Main namespace for Aleph-w library functions.
 
namespace  Aleph::detail
 

Functions

bool Aleph::is_leap_year (const size_t yy) noexcept
 Return true if the provided year is a leap year.
 
bool Aleph::valid_month (const size_t mm) noexcept
 Check whether the month number is within the [1, 12] range.
 
bool Aleph::valid_day (const size_t yy, const size_t mm, const size_t dd) noexcept
 Check whether a given day exists for the supplied month/year.
 
time_t Aleph::to_time_t (const size_t dd, const size_t mm, const size_t yy)
 Convert a (day, month, year) triple to a POSIX time_t value.
 
time_t Aleph::to_time_t (const std::string &s, const std::string &format)
 Convert a formatted string to time_t using the provided format.
 
time_t Aleph::to_time_t (const std::string &s)
 Convenience overload for ISO strings (YYYY-MM-DD HH:MM:SS).
 
size_t Aleph::to_days (const time_t t)
 Return the number of whole days represented by t.
 
std::string Aleph::to_string (const time_t t, const std::string &format)
 Format a time_t value into a string using format.
 

Variables

constexpr size_t Aleph::detail::tm_epoch_year = 1900u
 
constexpr size_t Aleph::detail::max_supported_year
 
constexpr time_t Aleph::detail::seconds_per_day
 

Detailed Description

Lightweight helpers for validating and formatting civil dates.

These functions wrap POSIX strptime/mktime functionality with Aleph-w error handling in order to surface invalid inputs early and to provide a consistent interface for common conversions involving time_t.

Author
Leandro Rabindranath León

Definition in file ah-date.H.