CoreComponents 3.0.0
A Modern C++ Toolkit
Loading...
Searching...
No Matches

Calendar date and time. More...

#include <cc/Date>

Public Member Functions

 Date ()
 Create an invalid date.
 
 Date (double time, int offset=0)
 Create a calendar date by breaking down a timestamp.
 
 Date (int year, int month, int day, int hour=0, int minutes=0, int seconds=0, int offset=0)
 Compose a calendar date from calendar components.
 
bool isValid () const
 Tell if this is a date is valid.
 
double time () const
 Seconds since the begin of Epoch (1st Jan 1970 00:00:00)
 
 operator bool () const
 Tell if this is a date is valid.
 
 operator double () const
 Seconds since the begin of Epoch (1st Jan 1970 00:00:00)
 
 operator String () const
 Return textual representation of this date
 
int offset () const
 Time zone offset in seconds.
 
int year () const
 Year number (1, 2,..., 2020, etc.)
 
int month () const
 Month number (1..12)
 
int day () const
 Day of month (1..31)
 
int weekDay () const
 Day of the week (0..6)
 
int yearDay () const
 Day of the year (1..365)
 
int hour () const
 Hour of the day (0..23)
 
int minutes () const
 Minutes (0..60)
 
int seconds () const
 Seconds (0..60)
 
String monthName () const
 Name of the month ("Jan", "Feb", ..., "Dec")
 
String dayName () const
 Name of the weekday ("Sun", "Mon", ..., "Sat")
 
String toString () const
 Return textual representation of this date
 
double operator- (const Date &other) const
 Time difference in number of seconds.
 
bool operator== (const Date &other) const
 Equal to operator.
 
std::strong_ordering operator<=> (const Date &other) const
 Ordering operator.
 

Static Public Member Functions

static Date now ()
 Get the current UTC date and time.
 

Detailed Description

Calendar date and time.

Todo
toString(): fully enable ms resolution (ss.fraction in String output)
See also
Timezone

Constructor & Destructor Documentation

◆ Date() [1/3]

Date ( )

Create an invalid date.

◆ Date() [2/3]

Date ( double time,
int offset = 0 )
explicit

Create a calendar date by breaking down a timestamp.

Parameters
timeSeconds since the begin of Epoch (1st Jan 1970 00:00:00)
offsetTime zone offset in seconds.
See also
Timezone::offset()

◆ Date() [3/3]

Date ( int year,
int month,
int day,
int hour = 0,
int minutes = 0,
int seconds = 0,
int offset = 0 )

Compose a calendar date from calendar components.

Parameters
yearYear number (1, 2,..., 2020, etc.)
monthMonth number (1..12)
dayDay of month (1..31)
hourHour of the day (0..23)
minutesMinutes (0..60)
secondsSeconds (0..60)
offsetTime zone offset in seconds.
See also
Timezone::offset()

Member Function Documentation

◆ now()

Date now ( )
static

Get the current UTC date and time.

◆ isValid()

bool isValid ( ) const

Tell if this is a date is valid.

◆ time()

double time ( ) const

Seconds since the begin of Epoch (1st Jan 1970 00:00:00)

◆ operator bool()

operator bool ( ) const
explicit

Tell if this is a date is valid.

◆ operator double()

operator double ( ) const

Seconds since the begin of Epoch (1st Jan 1970 00:00:00)

◆ operator String()

operator String ( ) const

Return textual representation of this date

◆ offset()

int offset ( ) const

Time zone offset in seconds.

See also
Timezone::offset()

◆ year()

int year ( ) const

Year number (1, 2,..., 2020, etc.)

◆ month()

int month ( ) const

Month number (1..12)

◆ day()

int day ( ) const

Day of month (1..31)

◆ weekDay()

int weekDay ( ) const

Day of the week (0..6)

◆ yearDay()

int yearDay ( ) const

Day of the year (1..365)

◆ hour()

int hour ( ) const

Hour of the day (0..23)

◆ minutes()

int minutes ( ) const

Minutes (0..60)

◆ seconds()

int seconds ( ) const

Seconds (0..60)

◆ monthName()

String monthName ( ) const

Name of the month ("Jan", "Feb", ..., "Dec")

◆ dayName()

String dayName ( ) const

Name of the weekday ("Sun", "Mon", ..., "Sat")

◆ toString()

String toString ( ) const

Return textual representation of this date

◆ operator-()

double operator- ( const Date & other) const

Time difference in number of seconds.

◆ operator==()

bool operator== ( const Date & other) const

Equal to operator.

◆ operator<=>()

std::strong_ordering operator<=> ( const Date & other) const

Ordering operator.