drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
drizzled::Date Class Reference

#include <temporal.h>

Inheritance diagram for drizzled::Date:
[legend]
Collaboration diagram for drizzled::Date:
[legend]

Public Member Functions

virtual bool operator== (const Date &rhs)
virtual bool operator!= (const Date &rhs)
virtual bool operator> (const Date &rhs)
virtual bool operator>= (const Date &rhs)
virtual bool operator< (const Date &rhs)
virtual bool operator<= (const Date &rhs)
virtual bool operator== (const DateTime &rhs)
virtual bool operator!= (const DateTime &rhs)
virtual bool operator> (const DateTime &rhs)
virtual bool operator>= (const DateTime &rhs)
virtual bool operator< (const DateTime &rhs)
virtual bool operator<= (const DateTime &rhs)
virtual bool operator== (const Timestamp &rhs)
virtual bool operator!= (const Timestamp &rhs)
virtual bool operator> (const Timestamp &rhs)
virtual bool operator>= (const Timestamp &rhs)
virtual bool operator< (const Timestamp &rhs)
virtual bool operator<= (const Timestamp &rhs)
const Date operator- (const Date &rhs)
const Date operator+ (const Date &rhs)
Date & operator+= (const Date &rhs)
Date & operator-= (const Date &rhs)
const Date operator- (const Time &rhs)
const Date operator+ (const Time &rhs)
Date & operator-= (const Time &rhs)
Date & operator+= (const Time &rhs)
const Date operator- (const DateTime &rhs)
const Date operator+ (const DateTime &rhs)
Date & operator+= (const DateTime &rhs)
Date & operator-= (const DateTime &rhs)
Date & operator= (const DateTime &rhs)
virtual bool is_valid_date () const
virtual bool is_valid_datetime () const
virtual bool is_valid_time () const
virtual bool is_valid_timestamp () const
virtual bool is_valid () const
virtual bool in_unix_epoch () const
virtual int to_string (char *to, size_t to_len) const
virtual bool from_string (const char *from, size_t from_len)
virtual void to_int64_t (int64_t *to) const
virtual void to_int32_t (int32_t *to) const
virtual bool from_int32_t (const int32_t from)
void to_julian_day_number (int64_t *to) const
bool from_julian_day_number (const int64_t from)
virtual void to_tm (struct tm *to) const
virtual bool from_tm (const struct tm *from)
virtual void to_time_t (time_t &to) const
virtual bool from_time_t (const time_t from)
virtual void to_decimal (type::Decimal *to) const
Public Member Functions inherited from drizzled::Temporal
enum calendar calendar () const
void set_nseconds (const uint32_t nsecond)
uint32_t nseconds () const
void set_useconds (const uint32_t usecond)
uint32_t useconds () const
void set_epoch_seconds ()
void set_epoch_seconds (const uint32_t epoch_second)
time_t epoch_seconds () const
void set_seconds (const uint32_t second)
uint32_t seconds () const
void set_minutes (const uint32_t minute)
uint32_t minutes () const
void set_hours (const uint32_t hour)
uint32_t hours () const
void set_days (const uint32_t day)
uint32_t days () const
void set_months (const uint32_t month)
uint32_t months () const
void set_years (const uint32_t year)
uint32_t years () const
bool overflow () const

Static Public Attributes

static const int MAX_STRING_LENGTH = 11

Friends

class TemporalInterval
class Timestamp

Additional Inherited Members

Protected Member Functions inherited from drizzled::Temporal
uint64_t _cumulative_seconds_in_time () const
void _reset ()
Protected Attributes inherited from drizzled::Temporal
enum calendar _calendar
uint32_t _years
uint32_t _months
uint32_t _days
uint32_t _hours
uint32_t _minutes
uint32_t _seconds
time_t _epoch_seconds
uint32_t _useconds
uint32_t _nseconds
bool _overflow

Detailed Description

Class representing temporal components in a valid SQL date range, with no time component

Definition at line 191 of file temporal.h.

Constructor & Destructor Documentation

◆ Date()

drizzled::Date::Date ( )
inline

Definition at line 194 of file temporal.h.

Member Function Documentation

◆ from_int32_t()

bool drizzled::Date::from_int32_t ( const int32_t from)
virtual

Attempts to populate the Date instance based on the contents of a supplied 4-byte integer.

Returns whether the conversion was successful.

Parameters
Integerto convert from

Ignore overflow and pass-through to DateTime::from_int64_t()

Reimplemented in drizzled::DateTime.

Definition at line 1083 of file temporal.cc.

◆ from_julian_day_number()

bool drizzled::Date::from_julian_day_number ( const int64_t from)

Attempts to populate the Date instance based on the contents of a supplied Julian Day Number

Returns whether the conversion was successful.

Parameters
Integerto convert from

Definition at line 1069 of file temporal.cc.

◆ from_string()

bool drizzled::Date::from_string ( const char * from,
size_t from_len )
virtual

Attempts to populate the Date instance based on the contents of a supplied string.

Returns whether the conversion was successful.

Parameters
Stringto convert from
Lengthof supplied string (not including trailing '\0').

Reimplemented in drizzled::DateTime.

Definition at line 109 of file temporal.cc.

◆ from_time_t()

bool drizzled::Date::from_time_t ( const time_t from)
virtual

Attempts to populate the Date instance based on the contents of a supplied time_t

Returns whether the conversion was successful.

Parameters
time_tto convert from

Reimplemented in drizzled::DateTime.

Definition at line 1210 of file temporal.cc.

◆ from_tm()

bool drizzled::Date::from_tm ( const struct tm * from)
virtual

Attempts to populate the Date instance based on the contents of a supplied pointer to struct tm (broken time).

Returns whether the conversion was successful.

Parameters
Pointerto the struct tm to convert from

Definition at line 1166 of file temporal.cc.

◆ in_unix_epoch()

bool drizzled::Date::in_unix_epoch ( ) const
virtual

Reimplemented in drizzled::DateTime.

Definition at line 1156 of file temporal.cc.

◆ is_valid()

bool drizzled::Date::is_valid ( ) const
virtual

Returns whether the temporal value is valid date.

Implements drizzled::Temporal.

Reimplemented in drizzled::DateTime, drizzled::MicroTimestamp, drizzled::NanoTimestamp, and drizzled::Timestamp.

Definition at line 1315 of file temporal.cc.

◆ is_valid_date()

virtual bool drizzled::Date::is_valid_date ( ) const
inlinevirtual

Returns whether the temporal value is valid as a date.

Implements drizzled::Temporal.

Definition at line 280 of file temporal.h.

◆ is_valid_datetime()

virtual bool drizzled::Date::is_valid_datetime ( ) const
inlinevirtual

Returns whether the temporal value is valid as a datetime.

Implements drizzled::Temporal.

Definition at line 281 of file temporal.h.

◆ is_valid_time()

virtual bool drizzled::Date::is_valid_time ( ) const
inlinevirtual

Returns whether the temporal value is valid as a time.

Implements drizzled::Temporal.

Definition at line 282 of file temporal.h.

◆ is_valid_timestamp()

virtual bool drizzled::Date::is_valid_timestamp ( ) const
inlinevirtual

Returns whether the temporal value is valid as a UNIX timestamp.

Implements drizzled::Temporal.

Reimplemented in drizzled::Timestamp.

Definition at line 283 of file temporal.h.

◆ operator!=() [1/3]

bool drizzled::Date::operator!= ( const Date & rhs)
virtual

Definition at line 268 of file temporal.cc.

◆ operator!=() [2/3]

bool drizzled::Date::operator!= ( const DateTime & rhs)
virtual

Definition at line 311 of file temporal.cc.

◆ operator!=() [3/3]

bool drizzled::Date::operator!= ( const Timestamp & rhs)
virtual

Definition at line 775 of file temporal.cc.

◆ operator+() [1/3]

const Date drizzled::Date::operator+ ( const Date & rhs)

@TODO Need an exception check here for bounds of JDN...

Definition at line 528 of file temporal.cc.

◆ operator+() [2/3]

const Date drizzled::Date::operator+ ( const DateTime & rhs)

@TODO Need an exception check here for bounds of JDN...

Definition at line 632 of file temporal.cc.

◆ operator+() [3/3]

const Date drizzled::Date::operator+ ( const Time & rhs)

Definition at line 394 of file temporal.cc.

◆ operator+=() [1/3]

Date & drizzled::Date::operator+= ( const Date & rhs)

@TODO Need an exception check here for bounds of JDN...

Definition at line 556 of file temporal.cc.

◆ operator+=() [2/3]

Date & drizzled::Date::operator+= ( const DateTime & rhs)

@TODO Need an exception check here for bounds of JDN...

Definition at line 722 of file temporal.cc.

◆ operator+=() [3/3]

Date & drizzled::Date::operator+= ( const Time & rhs)

@TODO Once exceptions are supported, we should raise an error here if the result Time is not valid?

Definition at line 441 of file temporal.cc.

◆ operator-() [1/3]

const Date drizzled::Date::operator- ( const Date & rhs)

Operator overload for adding/subtracting another Date (or subclass) to/from this temporal. When subtracting or adding two Dates, we return a new Date instance.

Parameters
Dateinstance to add/subtract to/from

We can add/subtract two Dates to/from each other. The result is always another Date instance.

Definition at line 516 of file temporal.cc.

◆ operator-() [2/3]

const Date drizzled::Date::operator- ( const DateTime & rhs)

Operator overload for adding/subtracting a DateTime (or subclass) to/from this temporal. When subtracting or adding two Dates, we return a new Date instance.

Parameters
DateTimeinstance to add/subtract to/from

We can add/subtract two DateTimes to/from each other. The result is always another DateTime instance.

Definition at line 588 of file temporal.cc.

◆ operator-() [3/3]

const Date drizzled::Date::operator- ( const Time & rhs)

Operator to add/subtract a Time from a Time. We can return a Time new temporal instance.

Parameters
Temporalinstance to add/subtract to/from

We can add or subtract a Time value to/from a DateTime value as well...it always produces a DateTime.

Definition at line 350 of file temporal.cc.

◆ operator-=() [1/3]

Date & drizzled::Date::operator-= ( const Date & rhs)

Definition at line 546 of file temporal.cc.

◆ operator-=() [2/3]

Date & drizzled::Date::operator-= ( const DateTime & rhs)

Definition at line 679 of file temporal.cc.

◆ operator-=() [3/3]

Date & drizzled::Date::operator-= ( const Time & rhs)

@TODO Once exceptions are supported, we should raise an error here if the result Time is not valid?

Definition at line 474 of file temporal.cc.

◆ operator<() [1/3]

bool drizzled::Date::operator< ( const Date & rhs)
virtual

Definition at line 272 of file temporal.cc.

◆ operator<() [2/3]

bool drizzled::Date::operator< ( const DateTime & rhs)
virtual

Definition at line 315 of file temporal.cc.

◆ operator<() [3/3]

bool drizzled::Date::operator< ( const Timestamp & rhs)
virtual

Definition at line 779 of file temporal.cc.

◆ operator<=() [1/3]

bool drizzled::Date::operator<= ( const Date & rhs)
virtual

Definition at line 278 of file temporal.cc.

◆ operator<=() [2/3]

bool drizzled::Date::operator<= ( const DateTime & rhs)
virtual

Definition at line 326 of file temporal.cc.

◆ operator<=() [3/3]

bool drizzled::Date::operator<= ( const Timestamp & rhs)
virtual

Definition at line 793 of file temporal.cc.

◆ operator=()

Date & drizzled::Date::operator= ( const DateTime & rhs)

Operator overload for when a DateTime instance is assigned to a Date. We do a copy of the DateTime's date-related components.

Parameters
TheDateTime to copy from

Definition at line 573 of file temporal.cc.

◆ operator==() [1/3]

bool drizzled::Date::operator== ( const Date & rhs)
virtual

Comparison operator overloads to compare a Date against another Date value.

Parameters
Dateto compare against.

Reimplemented in drizzled::Timestamp.

Definition at line 260 of file temporal.cc.

◆ operator==() [2/3]

bool drizzled::Date::operator== ( const DateTime & rhs)
virtual

Comparison operator overloads to compare a Date against a DateTime value.

Parameters
DateTimeto compare against.

Reimplemented in drizzled::Timestamp.

Definition at line 298 of file temporal.cc.

◆ operator==() [3/3]

bool drizzled::Date::operator== ( const Timestamp & rhs)
virtual

Comparison operator overloads to compare this against a Timestamp value.

Parameters
Timestampto compare against.

Reimplemented in drizzled::Timestamp.

Definition at line 771 of file temporal.cc.

◆ operator>() [1/3]

bool drizzled::Date::operator> ( const Date & rhs)
virtual

Definition at line 284 of file temporal.cc.

◆ operator>() [2/3]

bool drizzled::Date::operator> ( const DateTime & rhs)
virtual

Definition at line 337 of file temporal.cc.

◆ operator>() [3/3]

bool drizzled::Date::operator> ( const Timestamp & rhs)
virtual

Definition at line 797 of file temporal.cc.

◆ operator>=() [1/3]

bool drizzled::Date::operator>= ( const Date & rhs)
virtual

Definition at line 288 of file temporal.cc.

◆ operator>=() [2/3]

bool drizzled::Date::operator>= ( const DateTime & rhs)
virtual

Definition at line 341 of file temporal.cc.

◆ operator>=() [3/3]

bool drizzled::Date::operator>= ( const Timestamp & rhs)
virtual

Definition at line 801 of file temporal.cc.

◆ to_decimal()

void drizzled::Date::to_decimal ( type::Decimal * to) const
virtual

Fills a supplied type::Decimal with a representation of the Date value.

Parameters
Pointerto the type::Decimal to fill

Reimplemented in drizzled::DateTime.

Definition at line 996 of file temporal.cc.

◆ to_int32_t()

void drizzled::Date::to_int32_t ( int32_t * to) const
virtual

Fills a supplied 4-byte integer pointer with an integer representation of the Date value.

Parameters
Integerto fill.

Reimplemented in drizzled::DateTime.

Definition at line 1019 of file temporal.cc.

◆ to_int64_t()

void drizzled::Date::to_int64_t ( int64_t * to) const
virtual

Fills a supplied 8-byte integer pointer with an integer representation of the Date value.

Parameters
Integerto fill.

Reimplemented in drizzled::DateTime.

Definition at line 1014 of file temporal.cc.

◆ to_julian_day_number()

void drizzled::Date::to_julian_day_number ( int64_t * to) const

Fills a supplied int64_t with the Julian Day Number representation of this Date.

Note
Julian Day Number != julian day!

Julian Day Number is the monotonically increasing number of days from the start of the Julian calendar (~4713 B.C.)

julian day is the ordinal day number of a day in a year.

Parameters
int64_tto fill

Definition at line 1075 of file temporal.cc.

◆ to_string()

int drizzled::Date::to_string ( char * to,
size_t to_len ) const
virtual

Fills a supplied char string with a string representation of the Date value.

Parameters
C-Stringto fill.
Lengthof to C-String
Returns
length of string written (including trailing '\0'). If output was truncated, returns length that would have been outputted.

Reimplemented in drizzled::DateTime, and drizzled::MicroTimestamp.

Definition at line 956 of file temporal.cc.

◆ to_time_t()

void drizzled::Date::to_time_t ( time_t & to) const
virtual

Attempts to convert the Date value into a supplied time_t.

Parameters
Pointerto a time_t to convert to

Reimplemented in drizzled::Timestamp.

Definition at line 1286 of file temporal.cc.

◆ to_tm()

void drizzled::Date::to_tm ( struct tm * to) const
virtual

Fills a supplied tm pointer with an representation of the Date value.

Parameters
tmto fill.

Reimplemented in drizzled::DateTime.

Definition at line 1049 of file temporal.cc.

◆ TemporalInterval

friend class TemporalInterval
friend

Definition at line 427 of file temporal.h.

◆ Timestamp

friend class Timestamp
friend

Definition at line 428 of file temporal.h.

Member Data Documentation

◆ MAX_STRING_LENGTH

const int drizzled::Date::MAX_STRING_LENGTH = 11
static

Maximum length of C-String needed to represent type (including '\0').

Definition at line 310 of file temporal.h.


The documentation for this class was generated from the following files: