![]() |
MySQL 9.7.0
Source Code Documentation
|
Date_val is a temporal type that represents dates within the range 0000-01-01 and 9999-12-31. More...
#include <my_temporal.h>
Public Member Functions | |
| Date_val ()=default | |
| Date_val (uint32_t year, uint32_t month, uint32_t day) | |
| Date_val (const MYSQL_TIME &mtime) | |
| Date_val (uint32_t day_number) | |
| uint32_t | year () const |
| uint32_t | month () const |
| uint32_t | day () const |
| bool | is_zero_date () const |
| int | compare (const Date_val arg) const |
| int32_t | for_comparison () const |
| int | check_date (my_time_flags_t flags) const |
| Check date for validity, according to calendar and validation flags. More... | |
| uint32_t | day_number () const |
| void | set_zero () |
| Set zero date. More... | |
| bool | operator== (const Date_val rhs) const |
| bool | operator< (const Date_val rhs) const |
| bool | add (Interval &iv, bool subtract) |
| Add an interval to a date value, or subtract it. More... | |
| void | set_last_day_of_month () |
| Adjust date to have last day of month. More... | |
| operator MYSQL_TIME () const | |
| Convert date value to the generalized temporal time format. More... | |
| operator Datetime_val () const | |
| Convert date value to a datetime value, where time component is 00:00:00. More... | |
| int32_t | to_int () const |
| double | to_double () const |
| void | store_date (uint8_t *ptr) const |
| Convert server date value to storage engine interface format. More... | |
| size_t | to_string (char *buffer) const |
| std::string | to_string () const |
Static Public Member Functions | |
| static uint32_t | last_day_number () |
| static int | make_date (uint32_t year, uint32_t month, uint32_t day, my_time_flags_t flags, Date_val *date) |
| Make date from year, month and day components, according to validation flags. More... | |
| static Date_val | strip_time (const MYSQL_TIME &mtime) |
| Creates a Date_val from a date_time by extracting only the date fields. More... | |
| static void | load_date (const uint8_t *ptr, Date_val *date) |
| Convert from storage engine interface date format to server date value. More... | |
Private Member Functions | |
| bool | is_valid () const |
| Internal date validity check. Zero date, invalid calendar dates are OK. More... | |
Static Private Member Functions | |
| static bool | is_leap_year (uint32_t year) |
| static void | day_number_to_date (uint32_t daynr, uint32_t *year, uint32_t *month, uint32_t *day) |
| Convert day number to date. More... | |
Private Attributes | |
| uint32_t | m_value = 0xffffffff |
| A DATE value is stored in bit coded fields in a 32 bit unsigned value. More... | |
Static Private Attributes | |
| static constexpr const uint32_t | DATE_MAX_YEAR = 9999 |
| static constexpr const uint32_t | DATE_MAX_MONTH = 12 |
| static constexpr const uint32_t | DATE_MAX_DAY = 31 |
| static constexpr const uint32_t | DATE_DAYS_IN_YEAR = 365 |
| static constexpr const uint32_t | DATE_DAYS_IN_LEAP = 366 |
| static constexpr const uint32_t | DATE_BITS_YEAR = 0x007FFE00 |
| static constexpr const uint32_t | DATE_BITS_MONTH = 0x000001E0 |
| static constexpr const uint32_t | DATE_BITS_DAY = 0x0000001F |
| static constexpr const int | DATE_SHIFT_YEAR = 9 |
| static constexpr const int | DATE_SHIFT_MONTH = 5 |
| static constexpr const uint32_t | DATE_LAST_DAY = 3652424 |
Date_val is a temporal type that represents dates within the range 0000-01-01 and 9999-12-31.
In addition, dates with zero values for date and month are supported, for use with certain relaxed SQL modes. Furthermore, a date object may accept invalid dates, but only with day values not greater than 31 and year and month values must be in the supported range.
Date_val implements a proleptic Gregorian calendar, where the rules for leap years are extended back to year 0, except that year 0 itself is not a leap year, even though it matches the common rule. The latter is for compatibility with older implementations.
The SQL standard is defined for years in range from 0 to 9999, thus the range that MySQL supports is standard compliant.
The class has constructors for creating date values from date components (year, month and day), and from MYSQL_TIME objects.
|
default |
|
inline |
|
inlineexplicit |
|
inlineexplicit |
|
inline |
|
inline |
|
inline |
|
inlinestaticprivate |
|
inlineprivate |
Internal date validity check. Zero date, invalid calendar dates are OK.
|
inline |
|
inlinestatic |
|
inlinestatic |
Convert from storage engine interface date format to server date value.
| ptr | The pointer to read the value at. | |
| [out] | date | Returned date value |
|
inline |
|
inline |
|
inline |
|
inline |
Set zero date.
|
inline |
Convert server date value to storage engine interface format.
| [out] | ptr | The buffer to put value at. |
|
inline |
|
inline |
|
staticconstexprprivate |
|
staticconstexprprivate |
|
staticconstexprprivate |
|
staticconstexprprivate |
|
staticconstexprprivate |
|
staticconstexprprivate |
|
staticconstexprprivate |
|
staticconstexprprivate |
|
staticconstexprprivate |
|
staticconstexprprivate |
|
staticconstexprprivate |
|
private |
A DATE value is stored in bit coded fields in a 32 bit unsigned value.
The format is efficient for comparison, storage, retrieval and movement. Values can be compared using regular unsigned integer logic. The initial value is invalid, thus a separate initialization is required for this member. Format: Bits 0- 4: day (0-31) Bits 5- 8: month (0-12) Bits 9-22: year (0-9999)