Represents a day between January 1, Year 1 and a few thousand years in the future.
None of its members should be accessed directly.
If the Date-struct is obtained from g_date_new
, it will be safe to mutate but invalid and thus
not safe for calendrical computations.
If it's declared on the stack, it will contain garbage so must be initialized with clear
. clear makes the date invalid but sane. An invalid date doesn't represent a day,
it's "empty." A date becomes valid after you set it to a Julian day or you set a day, month, and year.
- public void clear (uint n_dates = 1)
Initializes one or more Date structs to a
sane but invalid state.
- public void set_day (DateDay day)
Sets the day of the month for a Date.
- public void set_month (DateMonth month)
Sets the month of the year for a Date.
- public void set_year (DateYear year)
Sets the year for a Date.
- public void set_dmy (DateDay day, int month, DateYear y)
Sets the value of a Date from a day,
month, and year.
- public void set_julian (uint julian_day)
Sets the value of a Date from a Julian day
number.
- public void set_time_t (time_t timet)
Sets the value of a date to the date corresponding to a time specified
as a time_t.
- public void set_time_val (TimeVal timeval)
Sets the value of a date from a
TimeVal value.
- public void set_parse (string str)
Parses a user-inputted string str
, and try to figure out
what date it represents, taking the current locale into account.
- public void add_days (uint n_days)
Increments a date some number of days.
- public void subtract_days (uint n_days)
Moves a date some number of days into the past.
- public void add_months (uint n_months)
Increments a date by some number of months.
- public void subtract_months (uint n_months)
Moves a date some number of months into the past.
- public void add_years (uint n_years)
Increments a date by some number of years.
- public void subtract_years (uint n_years)
Moves a date some number of years into the past.
- public int days_between (Date date2)
Computes the number of days between two dates.
- public int compare (Date rhs)
qsort
-style comparison function for dates.
- public void clamp (Date min_date, Date max_date)
If this is prior to min_date
, sets this equal to min_date
.
- public void order (Date date2)
Checks if this is less than or equal
to date2
, and swap the values if this is not the case.
- public DateDay get_day ()
Returns the day of the month.
- public DateMonth get_month ()
Returns the month of the year.
- public DateYear get_year ()
Returns the year of a Date.
- public uint get_julian ()
Returns the Julian day or "serial number" of the
Date.
- public DateWeekday get_weekday ()
Returns the day of the week for a Date.
- public uint get_day_of_year ()
Returns the day of the year, where Jan 1 is the first day of the year.
- public bool is_first_of_month ()
Returns true if the date
is on the first of a month.
- public bool is_last_of_month ()
Returns true if the date
is the last day of the month.
- public uint get_monday_week_of_year ()
Returns the week of the year, where weeks are understood to start on
Monday.
- public uint get_sunday_week_of_year ()
Returns the week of the year during which this date falls, if weeks
are understood to being on Sunday.
- public uint get_iso8601_week_of_year ()
Returns the week of the year, where weeks are interpreted according to
ISO 8601.
- public size_t strftime (char[] s, string format)
Generates a printed representation of the date, in a locale
-specific way.
- public void to_time (out Time tm)
Fills in the date-related bits of a struct tm using the
this value.
- public bool valid ()
Returns true if the
Date represents an existing day.