Thread portable class


Gate portable class


Timer class


Pool class


Terimber 2.0


About C++


Downloads Products & Services Support Clients Open Source About



Home / Open source / Terimber 2.0

date Class Reference

datetime up to milliseconds More...

#include <date.h>

List of all members.

Public Member Functions

 date (bool utc=false)
 default constructor
 date (const char *x, size_t len=os_minus_one)
 constructor scans narrow string format
 date (const wchar_t *x, size_t len=os_minus_one)
 constructor scans wide string format
 date (const double *x)
 constructor from pointer to double
 date (double x)
 constructor from double
 date (sb8_t x)
 constructor from ticks in milliseconds from 1 A.D.
 operator double () const
 converts to double
 operator sb8_t () const
 converts to ticks in milliseconds from 1 A.D.
bool operator< (const date &x) const
 less operator
bool operator== (const date &x) const
 eqaul operator
bool operator!= (const date &x) const
 non equal operator
bool operator<= (const date &x) const
 less or equal operator
bool operator> (const date &x) const
 greater operator
bool operator>= (const date &x) const
 greater or equal operator
bool is_time_over (sb8_t x) const
 checks if current time exceed the specified one
dateoperator+= (sb8_t interval)
 plus assign operator
dateoperator-= (sb8_t interval)
 minus assign operator
const char * get_date (char *buffer) const
 narrow string format data
const wchar_tget_date (wchar_t *buffer) const
 wide string format data
const char * get_date_only (char *buffer, const char *format) const
 narrow string format data
const wchar_tget_date_only (wchar_t *buffer, const wchar_t *format) const
 wide string format data

Static Public Member Functions

static bool convert_to (ub4_t year, ub1_t month, ub1_t day, ub1_t hour, ub1_t minute, ub1_t second, ub2_t millisec, sb8_t &dt)
 converts from struct members to ticks
static bool convert_from (sb8_t dt, ub4_t &year, ub1_t &month, ub1_t &day, ub1_t &hour, ub1_t &minute, ub1_t &second, ub2_t &millisec, ub1_t &wday, ub2_t &yday)
 converts from ticks to struct members
static sb8_t get_difference (sb8_t old_date)
 gets the difference between current time and the specified one

Private Member Functions

void set_date (const char *x)
 sets the date from formatted narrow string "%d-%02d-%02d %02d-%02d-%02d.%04d"
void set_date (const wchar_t *x)
 sets the date from formatted wide string "%d-%02d-%02d %02d-%02d-%02d.%04d"
void set_double (double x)
 sets date from double

Static Private Member Functions

static bool scan_buffer (const char *&x, size_t count, size_t delimeter_size, sb4_t &dest)
 scans buffer of narrow chars moving pointer on count chars forward
static bool scan_buffer (const wchar_t *&x, size_t count, size_t delimeter_size, sb4_t &dest)
 scans buffer of narrow chars moving pointer on count chars forward

Private Attributes

sb8_t _ticks
 ticks in millisecond after 1 January 0000, midnight (negative value means before)

Static Private Attributes

static ub2_t _month_days [13]
 static array of days in month
static const sb8_t _70years = 25569
 days in 70 years
static const sb8_t _1899years = 693959
 days from 0 year A.D. to 12 December 1899
static const sb8_t _daymillisecond = 86400000
 millisecond in one day


Detailed Description

datetime up to milliseconds

Definition at line 38 of file date.h.


Constructor & Destructor Documentation

date::date ( bool  utc = false  ) 

default constructor

Definition at line 48 of file date.cpp.

References _1899years, _70years, _daymillisecond, and _ticks.

Referenced by get_difference().

date::date ( const char *  x,
size_t  len = os_minus_one 
)

constructor scans narrow string format

Parameters:
x  input
len  input length

Definition at line 67 of file date.cpp.

References os_minus_one, set_date(), str_template::strcpy(), and str_template::strlen().

date::date ( const wchar_t x,
size_t  len = os_minus_one 
)

constructor scans wide string format

Parameters:
x  input
len  input length

Definition at line 79 of file date.cpp.

References os_minus_one, set_date(), str_template::strcpy(), and str_template::strlen().

date::date ( const double *  x  ) 

constructor from pointer to double

Parameters:
x  input

Definition at line 97 of file date.cpp.

References set_double().

date::date ( double  x  ) 

constructor from double

Parameters:
x  input

Definition at line 104 of file date.cpp.

References set_double().

date::date ( sb8_t  x  ) 

constructor from ticks in milliseconds from 1 A.D.

Parameters:
x  input

Definition at line 91 of file date.cpp.

References _ticks.


Member Function Documentation

date::operator double (  )  const

converts to double

Definition at line 110 of file date.cpp.

References _1899years, _daymillisecond, and _ticks.

date::operator sb8_t (  )  const

converts to ticks in milliseconds from 1 A.D.

Definition at line 126 of file date.cpp.

References _ticks.

bool date::convert_to ( ub4_t  year,
ub1_t  month,
ub1_t  day,
ub1_t  hour,
ub1_t  minute,
ub1_t  second,
ub2_t  millisec,
sb8_t dt 
) [static]

converts from struct members to ticks

Parameters:
year  year [0 : 1000000]
month  month [1-12]
day  day [1-31]
hour  hour [0-23]
minute  minute [0-59]
second  second [0-59]
millisec  millisecond [0-999]
dt  [out] ticks in miiliseconds since 1A.D.

Definition at line 197 of file date.cpp.

References _daymillisecond, and _month_days.

Referenced by binder::set_as_date(), set_date(), orcl_dbserver::v_convert_one_value(), odbc_dbserver::v_convert_one_value(), mysql_dbserver::v_convert_one_value(), orcl_dbserver::v_rebind_one_param(), odbc_dbserver::v_rebind_one_param(), and mysql_dbserver::v_rebind_one_param().

bool date::convert_from ( sb8_t  dt,
ub4_t year,
ub1_t month,
ub1_t day,
ub1_t hour,
ub1_t minute,
ub1_t second,
ub2_t millisec,
ub1_t wday,
ub2_t yday 
) [static]

converts from ticks to struct members

Parameters:
dt  ticks ticks in miiliseconds since 1A.D.
year  [out] year [0 : 1000000]
month  [out] month [1-12]
day  [out] day [1-31]
hour  [out] hour [0-23]
minute  [out] minute [0-59]
second  [out] second [0-59]
millisec  [out] millisecond [0-999]
wday  [out] day of week [1-7]
yday  [out] day of year [1-366]

Definition at line 251 of file date.cpp.

References _daymillisecond, and _month_days.

Referenced by get_date(), get_date_only(), dbserver_impl::get_param_as_date(), memlookup::get_value_as_date(), terimber_db_value_vector_impl::get_value_as_date(), dbserver_impl::get_value_as_date(), orcl_dbserver::v_bind_one_param(), odbc_dbserver::v_bind_one_param(), and mysql_dbserver::v_bind_one_param().

bool date::operator< ( const date x  )  const

less operator

Definition at line 132 of file date.cpp.

References _ticks.

bool date::operator== ( const date x  )  const

eqaul operator

Definition at line 144 of file date.cpp.

References _ticks.

bool date::operator!= ( const date x  )  const

non equal operator

Definition at line 138 of file date.cpp.

References _ticks.

bool date::operator<= ( const date x  )  const

less or equal operator

Definition at line 150 of file date.cpp.

References _ticks.

bool date::operator> ( const date x  )  const

greater operator

Definition at line 156 of file date.cpp.

References _ticks.

bool date::operator>= ( const date x  )  const

greater or equal operator

Definition at line 162 of file date.cpp.

References _ticks.

bool date::is_time_over ( sb8_t  x  )  const

checks if current time exceed the specified one

Parameters:
x  input time

Definition at line 168 of file date.cpp.

References _ticks, and get_difference().

Referenced by msg_connection::is_last_activity_timeout().

sb8_t date::get_difference ( sb8_t  old_date  )  [static]

gets the difference between current time and the specified one

Parameters:
old_date  input time

Definition at line 176 of file date.cpp.

References date().

Referenced by keylocker::enter(), is_time_over(), and keylocker::lock().

date & date::operator+= ( sb8_t  interval  ) 

plus assign operator

Definition at line 182 of file date.cpp.

References _ticks.

date & date::operator-= ( sb8_t  interval  ) 

minus assign operator

Definition at line 189 of file date.cpp.

References _ticks.

const char * date::get_date ( char *  buffer  )  const

narrow string format data

Parameters:
buffer  [out] preallocated buffer

Definition at line 364 of file date.cpp.

References _ticks, convert_from(), and str_template::strprint().

Referenced by daemon::log_message(), msg_communicator::log_msg(), and persist_value().

const wchar_t * date::get_date ( wchar_t buffer  )  const

wide string format data

Parameters:
buffer  [out] preallocated buffer

Definition at line 378 of file date.cpp.

References _ticks, convert_from(), str_template::strformat(), and str_template::strprint().

const char * date::get_date_only ( char *  buffer,
const char *  format 
) const

narrow string format data

Parameters:
buffer  [out] preallocated buffer
format  format for 3 integers, year, month, day like "%d-%02d-%02d"

Definition at line 395 of file date.cpp.

References _ticks, convert_from(), and str_template::strprint().

const wchar_t * date::get_date_only ( wchar_t buffer,
const wchar_t format 
) const

wide string format data

Parameters:
buffer  [out] preallocated buffer
format  format for 3 integers, year, month, day like "%d-%02d-%02d"

Definition at line 409 of file date.cpp.

References _ticks, convert_from(), str_template::strformat(), and str_template::strprint().

void date::set_date ( const char *  x  )  [private]

sets the date from formatted narrow string "%d-%02d-%02d %02d-%02d-%02d.%04d"

Parameters:
x  input

Definition at line 451 of file date.cpp.

References _ticks, convert_to(), and scan_buffer().

Referenced by date().

void date::set_date ( const wchar_t x  )  [private]

sets the date from formatted wide string "%d-%02d-%02d %02d-%02d-%02d.%04d"

Parameters:
x  input

Definition at line 476 of file date.cpp.

References _ticks, convert_to(), and scan_buffer().

bool date::scan_buffer ( const char *&  x,
size_t  count,
size_t  delimeter_size,
sb4_t dest 
) [static, private]

scans buffer of narrow chars moving pointer on count chars forward

Parameters:
x  input narrow string
count  chars for scan
delimeter_size  delimeter size
dest  [out] signed integer

Definition at line 426 of file date.cpp.

References str_template::strscan().

Referenced by set_date().

bool date::scan_buffer ( const wchar_t *&  x,
size_t  count,
size_t  delimeter_size,
sb4_t dest 
) [static, private]

scans buffer of narrow chars moving pointer on count chars forward

Parameters:
x  input wide string
count  chars for scan
delimeter_size  delimeter size
dest  [out] signed integer

Definition at line 439 of file date.cpp.

References str_template::strscan().

void date::set_double ( double  x  )  [private]

sets date from double

Parameters:
x  input

Definition at line 119 of file date.cpp.

References _1899years, _daymillisecond, and _ticks.

Referenced by date().


Member Data Documentation

sb8_t date::_ticks [private]

ticks in millisecond after 1 January 0000, midnight (negative value means before)

Definition at line 175 of file date.h.

Referenced by date(), get_date(), get_date_only(), is_time_over(), operator double(), operator sb8_t(), operator!=(), operator+=(), operator-=(), operator<(), operator<=(), operator==(), operator>(), operator>=(), set_date(), and set_double().

ub2_t date::_month_days [static, private]

Initial value:

        {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}
static array of days in month

Definition at line 176 of file date.h.

Referenced by convert_from(), and convert_to().

BEGIN_TERIMBER_NAMESPACE const sb8_t date::_70years = 25569 [static, private]

days in 70 years

Definition at line 177 of file date.h.

Referenced by date().

const sb8_t date::_1899years = 693959 [static, private]

days from 0 year A.D. to 12 December 1899

Definition at line 178 of file date.h.

Referenced by date(), operator double(), and set_double().

const sb8_t date::_daymillisecond = 86400000 [static, private]

millisecond in one day

Definition at line 179 of file date.h.

Referenced by convert_from(), convert_to(), date(), operator double(), and set_double().


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


© Copyright Terimber 2003-.