17 #include "present/internal/cpp-guard.h"
18 #include "present/internal/header-utils.h"
21 #include "present/internal/present-date-data.h"
23 #ifndef _PRESENT_DATE_H_
24 #define _PRESENT_DATE_H_
74 unsigned int month_out_of_range : 1,
76 week_of_year_out_of_range : 1,
77 day_of_week_out_of_range : 1;
81 struct PresentDateData data_;
94 static Date from_year_day(
99 static Date from_year_week_day(
153 static short compare(
const Date & lhs,
const Date & rhs);
156 friend bool operator==(
const Date & lhs,
const Date & rhs);
157 friend bool operator!=(
const Date & lhs,
const Date & rhs);
160 friend bool operator<(
const Date & lhs,
const Date & rhs);
162 friend bool operator<=(
const Date & lhs,
const Date & rhs);
164 friend bool operator>(
const Date & lhs,
const Date & rhs);
166 friend bool operator>=(
const Date & lhs,
const Date & rhs);
184 PRESENT_API
struct Date
206 PRESENT_API
struct Date
215 struct Date *
const result,
232 PRESENT_API
struct Date
241 struct Date *
const result,
256 #define Date_create(...) \
257 PRESENT_OVERLOAD_MAX_3(__VA_ARGS__, \
258 Date_from_year_month_day, \
259 Date_from_year_month, \
274 #define Date_ptr_create(result, ...) \
275 PRESENT_OVERLOAD_MAX_3(__VA_ARGS__, \
276 Date_ptr_from_year_month_day, \
277 Date_ptr_from_year_month, \
278 Date_ptr_from_year, \
279 dummy)(result, __VA_ARGS__)
287 PRESENT_API
struct Date
296 struct Date *
const result,
317 PRESENT_API
struct Date
329 struct Date *
const result,
379 const struct
Date *
const self,
380 const struct Date *
const other);
387 const struct
Date *
const self,
388 const struct Date *
const other);
395 struct Date *
const self,
396 const struct DayDelta *
const delta);
403 struct Date *
const self,
411 struct Date *
const self,
412 const struct DayDelta *
const delta);
419 struct Date *
const self,
431 const struct Date *
const lhs,
432 const struct Date *
const rhs);
452 const struct Date *
const lhs,
453 const struct Date *
const rhs);
460 const struct Date *
const lhs,
461 const struct Date *
const rhs);
469 const struct Date *
const lhs,
470 const struct Date *
const rhs);
void Date_subtract_MonthDelta(struct Date *const self, const struct MonthDelta *const delta)
Subtract a MonthDelta from a Date.
present_int16 int_day
Definition: types.h:66
int_day_of_week day_of_week() const
Get the day of the week of a Date (1 to 7, inclusive, with 1 being Monday, 2 being Tuesday...
Struct containing a year and a week of the year.
Definition: date.h:44
int_month month() const
Get the month of a Date (1 to 12, inclusive).
int_day_of_year Date_day_of_year(const struct Date *const self)
Get the day of the year of a Date (1 to 366, inclusive).
int_year year
Definition: date.h:46
short Date_compare(const struct Date *const lhs, const struct Date *const rhs)
Compare two Date instances.
struct Date Date_from_year_month(int_year year, int_month month)
Create a new Date based on a year and a month.
struct Date Date_from_year_month_day(int_year year, int_month month, int_day day)
Create a new Date based on a year, a month, and a day.
int_year year() const
Get the year of a Date.
present_int32 int_year
Definition: types.h:64
void Date_ptr_from_year_week_day(struct Date *const result, int_year year, int_week_of_year week_of_year, int_day_of_week day_of_week)
Create a new Date based on a year, a week of that year, and a day of the week.
int_day_of_week Date_day_of_week(const struct Date *const self)
Get the day of the week of a Date (1 to 7, inclusive, with 1 being Monday, 2 being Tuesday...
present_bool Date_less_than_or_equal(const struct Date *const lhs, const struct Date *const rhs)
Determine whether a Date is earlier than or the same as another Date (lhs <= rhs).
void Date_subtract_DayDelta(struct Date *const self, const struct DayDelta *const delta)
Subtract a DayDelta from a Date.
int_day Date_day(const struct Date *const self)
Get the day of month of a Date (1 to 31, inclusive).
void Date_ptr_from_year_month(struct Date *const result, int_year year, int_month month)
Create a new Date based on a year and a month.
struct Date Date_from_year(int_year year)
Create a new Date based on a year.
void Date_add_MonthDelta(struct Date *const self, const struct MonthDelta *const delta)
Add a MonthDelta to a Date.
struct Date Date_from_year_week_day(int_year year, int_week_of_year week_of_year, int_day_of_week day_of_week)
Create a new Date based on a year, a week of that year, and a day of the week.
present_bool Date_greater_than_or_equal(const struct Date *const lhs, const struct Date *const rhs)
Determine whether a Date is later than or the same as another Date (lhs >= rhs).
present_uint8 int_day_of_week
Definition: types.h:70
present_int16 int_month
Definition: types.h:65
void Date_ptr_from_year_day(struct Date *const result, int_year year, int_day_of_year day_of_year)
Create a new Date based on a year and the day of that year.
present_bool Date_greater_than(const struct Date *const lhs, const struct Date *const rhs)
Determine whether a Date is later than another Date (lhs > rhs).
struct DayDelta Date_difference(const struct Date *const self, const struct Date *const other)
Get the difference between two Date instances.
int_day_of_year day_of_year() const
Get the day of the year of a Date (1 to 366, inclusive).
struct Date Date_from_year_day(int_year year, int_day_of_year day_of_year)
Create a new Date based on a year and the day of that year.
int_week_of_year week
Definition: date.h:45
present_bool has_error
This will be true if there were any errors when creating this Date.
Definition: date.h:65
present_bool Date_less_than(const struct Date *const lhs, const struct Date *const rhs)
Determine whether a Date is earlier than another Date (lhs < rhs).
int_month Date_month(const struct Date *const self)
Get the month of a Date (1 to 12, inclusive).
present_int8 int_week_of_year
Definition: types.h:68
int_day day() const
Get the day of month of a Date (1 to 31, inclusive).
Class or struct representing a positive or negative delta of a number of days or weeks.
Definition: day-delta.h:40
Class or struct representing a calendar date.
Definition: date.h:59
void Date_add_DayDelta(struct Date *const self, const struct DayDelta *const delta)
Add a DayDelta to a Date.
struct DayDelta Date_absolute_difference(const struct Date *const self, const struct Date *const other)
Get the absolute difference between two Date instances.
void Date_ptr_from_year_month_day(struct Date *const result, int_year year, int_month month, int_day day)
Create a new Date based on a year, a month, and a day.
struct PresentWeekYear Date_week_of_year(const struct Date *const self)
Get the week of the year of a Date (1 to 53, inclusive), and the year corresponding to that week...
void Date_ptr_from_year(struct Date *const result, int_year year)
Create a new Date based on a year.
present_bool Date_equal(const struct Date *const lhs, const struct Date *const rhs)
Determine whether two Date instances are equal (lhs == rhs).
bool present_bool
Definition: types.h:21
int_year Date_year(const struct Date *const self)
Get the year of a Date.
PresentWeekYear week_of_year() const
Get the week of the year of a Date (1 to 53, inclusive), and the year corresponding to that week...
present_int16 int_day_of_year
Definition: types.h:67
Class or struct representing a positive or negative delta of a number of months or years...
Definition: month-delta.h:38