Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

PrevUpHomeNext

date

Type representing MySQL DATE data type.

Synopsis

Defined in header <boost/mysql/date.hpp>

class date
Types

Name

Description

time_point

A std::chrono::time_point that can represent any valid date.

Member Functions

Name

Description

as_local_time_point

Converts *this into a local time point (checked access).

as_time_point

Converts *this into a time_point (checked access).

date [constructor]

Constructs a zero date.

Constructs a date from its year, month and date components.

Constructs a date from a time_point.

Constructs a date from a local time point.

day

Retrieves the day component (1-based).

get_local_time_point

Converts *this into a local time point (unchecked access).

get_time_point

Converts *this into a time_point (unchecked access).

month

Retrieves the month component (1-based).

operator==

Tests for equality.

operator!=

Tests for inequality.

valid

Returns true if *this represents a valid time_point.

year

Retrieves the year component.

Static Member Functions

Name

Description

now

Returns the current system time as a date object.

Related Functions

Name

Description

operator<<

Streams a date.

Description

Represents a Gregorian date broken by its year, month and day components, without a time zone.

This type is close to the protocol and should not be used as a vocabulary type. Instead, cast it to a std::chrono::time_point by calling as_time_point, get_time_point, as_local_time_point or get_local_time_point.

Dates retrieved from MySQL don't include any time zone information. Determining the time zone is left to the application. Thus, any time point obtained from this class should be interpreted as a local time in an unspecified time zone, like std::chrono::local_time. For compatibility with older compilers, as_time_point and get_time_point return system_clock time points. These should be interpreted as local times rather than UTC. Prefer using as_local_time_point or get_local_time_point if your compiler supports them, as they provide more accurate semantics.

As opposed to time_point, this type allows representing MySQL invalid and zero dates. These values are allowed by MySQL but don't represent real dates.

Note: using std::chrono time zone functionality under MSVC may cause memory leaks to be reported. See this issue for an explanation and this other issue for a workaround.


PrevUpHomeNext