-
Notifications
You must be signed in to change notification settings - Fork 0
calendar.h ~ date ~ null_type
Baptiste Thémine edited this page Jun 9, 2020
·
8 revisions
typedef /* implementation defined */ null_type;
static constexpr null_type null = null_type();
Defines type to build a default 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 Period results in a null Period and vice-versa.
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