Skip to content

calendar.h ~ date ~ null_type

Baptiste Thémine edited this page Jul 5, 2020 · 8 revisions
typedef /* implementation defined */ null_type;
static constexpr null_type null = null_type();

Description

Defines type to build a default class Date object.

A null date is the earliest possible date in Gregorian calendar i.e. the first date of Anno Domini. It is represented in ISO 8601 as 0001-01-01T00:00:00+0000 and is in a valid state, thus its manipulation never throws exceptions as opposed to a null string. Casting a null date to a period results in a null period and vice-versa.

Examples

The following statements are equivalent but the first better expresses the intent.

Date date1 = date::null;                     //null date equals to null period
Date date2 = {};                             //C++11 default initialization
Date date3 = Date();                         //default date
Date date4 = Date(calendar::clock_type());   //default clock equals to 0
Date date5 = Date(0LL);                      //call clock constructor with duration of 0
Date date6 = Date(1);                        //call date/time constructor with year 0001
Date date7 = Date("0001-01-01");             //ISO 8601

See also

Clone this wiki locally