date.h Source File
|
CPP API
|
date.h
Go to the documentation of this file.
162 if (d_ <= 0 || d_ > ((is_leap_year(y_)) ? month_lengths_leap_year[m_ - 1] : month_lengths[m_ - 1]))
172 static constexpr std::array<int, 12> month_lengths = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
173 static constexpr std::array<int, 12> month_lengths_leap_year = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
205 std::partial_sum(date.month_lengths_leap_year.begin(), date.month_lengths_leap_year.end(), part_sum.begin());
257 // take month-2 since end of last month has to be found and due to start at 0 of C++ (against January=1 in date format)
294 // take month-2 since end of last month has to be found and due to start at 0 of C++ (against January=1 in date format)
A collection of classes to simplify handling of matrix shapes in meta programming.
Definition: models/abm/analyze_result.h:30
int get_month_length(Date date)
Computes the length of a month for a given date.
Definition: date.h:190
auto failure(const IOStatus &s)
Create an object that is implicitly convertible to an error IOResult<T>.
Definition: io.h:380
@ InvalidValue
@ OutOfRange
boost::outcome_v2::in_place_type_t< T > Tag
Type that is used for overload resolution.
Definition: io.h:407
details::ApplyResultT< F, T... > apply(IOContext &io, F f, const IOResult< T > &... rs)
Evaluate a function with zero or more unpacked IOResults as arguments.
Definition: io.h:481
std::string format_as(const mio::Date &d)
Format date objects using the ISO notation for logging with spdlog.
Definition: date.h:180
auto success()
Create an object that is implicitly convertible to a succesful IOResult<void>.
Definition: io.h:359
int get_offset_in_days(Date date1, Date date2)
Computes the offset in days given two dates: first date minus second date.
Definition: date.h:310
IOResult< Date > parse_date(const std::string &date_str)
parses a date from a string.
Definition: date.h:219
bool is_leap_year(int year)
Computes if a given year is a leap year.
Definition: date.h:41
std::array< int, 12 > calculate_partial_sum_of_months(const Date &date)
Computes the cumulative number of days at the end of each month for a given year.
Definition: date.h:201
Date offset_date_by_days(Date date, int offset_days)
Computes the new date corresponding to a given date and a offset in days.
Definition: date.h:242
boost::outcome_v2::unchecked< T, IOStatus > IOResult
Value-or-error type for operations that return a value but can fail.
Definition: io.h:353
int get_day_in_year(Date date)
Computes the day in year based on a given date.
Definition: date.h:284
friend std::ostream & operator<<(std::ostream &os, const Date &date)
Overload for stream operator to use the ISO 8601 format.
Definition: date.h:128
bool operator==(const Date &other) const
equality comparison operators.
Definition: date.h:78
static constexpr std::array< int, 12 > month_lengths_leap_year
Definition: date.h:173
std::string to_iso_string() const
Formats the date into a string in ISO 8601 format (YYYY-MM-DD).
Definition: date.h:113
static IOResult< Date > deserialize(IOContext &io)
deserialize an object of this class.
Definition: date.h:151
Generated by