Date/Time class. More...

#include <datetime.h>

Public Types

enum  TimeZone { local_timezone, utc_timezone }
 

Public Member Functions

 DateTime ()
 Constructs a date/time object. More...
 
 DateTime (int year, int month, int day, int hour=0, int minute=0, int seconds=0, int nanoseconds=0, TimeZone timezone=utc_timezone)
 
 ~DateTime ()
 
DateTimeadd_days (int days)
 
DateTimeadd_months (int months)
 
DateTimeadd_years (int years)
 
unsigned char day () const
 
unsigned int day_of_week () const
 Get the day of the week. More...
 
int difference_in_days (const DateTime &other) const
 Returns the difference in days between two dates. This function is only accurate for the next few millenniums. More...
 
unsigned char hour () const
 
bool is_null () const
 
unsigned char minutes () const
 
unsigned char month () const
 Returns the month number in range 1-12. More...
 
unsigned int nanoseconds () const
 
bool operator!= (const DateTime &other) const
 
bool operator< (const DateTime &other) const
 
bool operator<= (const DateTime &other) const
 
bool operator== (const DateTime &other) const
 
bool operator> (const DateTime &other) const
 
bool operator>= (const DateTime &other) const
 
unsigned char seconds () const
 
void set_date (int year, int month, int day, int hour=0, int minute=0, int seconds=0, int nanoseconds=0, TimeZone timezone=utc_timezone)
 
void set_day (int day)
 
void set_hour (int hour)
 
void set_minutes (int minutes)
 
void set_month (int month)
 
void set_nanoseconds (int nanoseconds)
 
void set_null ()
 
void set_seconds (int seconds)
 
void set_timezone (TimeZone timezone)
 
void set_year (int year)
 
TimeZone timezone () const
 
DateTime to_local () const
 
std::string to_long_date_string () const
 Mon Mar 3 2007. More...
 
std::string to_long_time_string () const
 hh:mm:ss More...
 
std::string to_short_date_string () const
 yyyy-mm-dd More...
 
std::string to_short_datetime_string () const
 yyyy-mm-dd hh:mm:ss More...
 
std::string to_short_time_string () const
 hh:mm More...
 
std::string to_string () const
 Mon Feb 3 12:32:54 2008. More...
 
int64_t to_ticks () const
 Converts the date to the number of 100-nanosecond intervals since January 1, 1601 UTC. More...
 
DateTime to_utc () const
 
unsigned char week () const
 Returns the ISO 8601 week number of the date. More...
 
unsigned short year () const
 

Static Public Member Functions

static DateTime current_local_time ()
 Get current system time in local time zone. More...
 
static DateTime current_utc_time ()
 Get current system time in UTC. More...
 
static int days_in_month (int month, int year)
 Returns the number of days in the given month. More...
 
static DateTime from_short_date_string (const std::string &value)
 
static DateTime local_time_from_ticks (int64_t ticks)
 Converts a time tick value (number of 100-nanosecond intervals since January 1, 1601 UTC) to a date time in the local time zone. More...
 
static DateTime utc_time_from_ticks (int64_t ticks)
 Converts a time tick value (number of 100-nanosecond intervals since January 1, 1601 UTC) to a date time in UTC. More...
 

Detailed Description

Date/Time class.

Member Enumeration Documentation

Enumerator
local_timezone 
utc_timezone 

Constructor & Destructor Documentation

uicore::DateTime::DateTime ( )

Constructs a date/time object.

uicore::DateTime::DateTime ( int  year,
int  month,
int  day,
int  hour = 0,
int  minute = 0,
int  seconds = 0,
int  nanoseconds = 0,
TimeZone  timezone = utc_timezone 
)
uicore::DateTime::~DateTime ( )

Member Function Documentation

DateTime& uicore::DateTime::add_days ( int  days)
DateTime& uicore::DateTime::add_months ( int  months)
DateTime& uicore::DateTime::add_years ( int  years)
static DateTime uicore::DateTime::current_local_time ( )
static

Get current system time in local time zone.

static DateTime uicore::DateTime::current_utc_time ( )
static

Get current system time in UTC.

unsigned char uicore::DateTime::day ( ) const
unsigned int uicore::DateTime::day_of_week ( ) const

Get the day of the week.

Returns
0 = Sunday ... 6 = Saturday
static int uicore::DateTime::days_in_month ( int  month,
int  year 
)
static

Returns the number of days in the given month.

Returns
number of days: 28-31.
int uicore::DateTime::difference_in_days ( const DateTime other) const

Returns the difference in days between two dates. This function is only accurate for the next few millenniums.

Returns
Number of days between dates. Returns a negative value if 'other' is before 'this'.
static DateTime uicore::DateTime::from_short_date_string ( const std::string value)
static
unsigned char uicore::DateTime::hour ( ) const
bool uicore::DateTime::is_null ( ) const
static DateTime uicore::DateTime::local_time_from_ticks ( int64_t  ticks)
static

Converts a time tick value (number of 100-nanosecond intervals since January 1, 1601 UTC) to a date time in the local time zone.

unsigned char uicore::DateTime::minutes ( ) const
unsigned char uicore::DateTime::month ( ) const

Returns the month number in range 1-12.

Returns
1 = Jan ... 12 = December
unsigned int uicore::DateTime::nanoseconds ( ) const
bool uicore::DateTime::operator!= ( const DateTime other) const
bool uicore::DateTime::operator< ( const DateTime other) const
bool uicore::DateTime::operator<= ( const DateTime other) const
bool uicore::DateTime::operator== ( const DateTime other) const
bool uicore::DateTime::operator> ( const DateTime other) const
bool uicore::DateTime::operator>= ( const DateTime other) const
unsigned char uicore::DateTime::seconds ( ) const
void uicore::DateTime::set_date ( int  year,
int  month,
int  day,
int  hour = 0,
int  minute = 0,
int  seconds = 0,
int  nanoseconds = 0,
TimeZone  timezone = utc_timezone 
)
void uicore::DateTime::set_day ( int  day)
void uicore::DateTime::set_hour ( int  hour)
void uicore::DateTime::set_minutes ( int  minutes)
void uicore::DateTime::set_month ( int  month)
void uicore::DateTime::set_nanoseconds ( int  nanoseconds)
void uicore::DateTime::set_null ( )
void uicore::DateTime::set_seconds ( int  seconds)
void uicore::DateTime::set_timezone ( TimeZone  timezone)
void uicore::DateTime::set_year ( int  year)
TimeZone uicore::DateTime::timezone ( ) const
DateTime uicore::DateTime::to_local ( ) const
std::string uicore::DateTime::to_long_date_string ( ) const

Mon Mar 3 2007.

std::string uicore::DateTime::to_long_time_string ( ) const

hh:mm:ss

std::string uicore::DateTime::to_short_date_string ( ) const

yyyy-mm-dd

std::string uicore::DateTime::to_short_datetime_string ( ) const

yyyy-mm-dd hh:mm:ss

std::string uicore::DateTime::to_short_time_string ( ) const

hh:mm

std::string uicore::DateTime::to_string ( ) const

Mon Feb 3 12:32:54 2008.

int64_t uicore::DateTime::to_ticks ( ) const

Converts the date to the number of 100-nanosecond intervals since January 1, 1601 UTC.

DateTime uicore::DateTime::to_utc ( ) const
static DateTime uicore::DateTime::utc_time_from_ticks ( int64_t  ticks)
static

Converts a time tick value (number of 100-nanosecond intervals since January 1, 1601 UTC) to a date time in UTC.

unsigned char uicore::DateTime::week ( ) const

Returns the ISO 8601 week number of the date.

Returns
Week number: 1-53.
unsigned short uicore::DateTime::year ( ) const

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