libdballe 9.6
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
dballe::Date Struct Reference

Calendar date. More...

#include <types.h>

Public Member Functions

 Date ()
 Construct a missing date.
 
 Date (int ye, int mo=1, int da=1)
 Construct from broken down values.
 
 Date (const Date &d)=default
 Copy constructor.
 
bool is_missing () const
 Check if this date is the missing value.
 
int to_julian () const
 Convert the date to Julian day.
 
void to_stream_iso8601 (std::ostream &out) const
 Write the date to an output stream in ISO8601 date format.
 
void to_csv_iso8601 (CSVWriter &out) const
 Write the date as a CSV field in ISO8601 date format.
 
int compare (const Date &other) const
 Generic comparison.
 
bool operator< (const Date &dt) const
 
bool operator> (const Date &dt) const
 
bool operator== (const Date &dt) const
 
bool operator!= (const Date &dt) const
 

Static Public Member Functions

static Date from_julian (int jday)
 Create a date from a Julian day.
 
static void validate (int ye, int mo, int da)
 Raise an exception if the three values do not represent a valid date.
 
static int days_in_month (int year, int month)
 Return the number of days in the given month.
 
static int calendar_to_julian (int year, int month, int day)
 Convert a calendar date into a Julian day.
 
static void julian_to_calendar (int jday, unsigned short &year, unsigned char &month, unsigned char &day)
 Convert a Julian day into a calendar date.
 

Public Attributes

unsigned short year
 
unsigned char month
 
unsigned char day
 

Detailed Description

Calendar date.

If year is 0xffff, then all the date is considered missing. Else, all fields must be set.

Constructor & Destructor Documentation

◆ Date()

dballe::Date::Date ( int  ye,
int  mo = 1,
int  da = 1 
)

Construct from broken down values.

A year of MISSING_INT constructs a missing Date. In any other case, arguments are validated with Date::validate().

Member Function Documentation

◆ compare()

int dballe::Date::compare ( const Date other) const

Generic comparison.

Returns a negative number if *this < other Returns zero if *this == other Returns a positive number if *this > other


The documentation for this struct was generated from the following file: