comet::datetime_t Class Reference
[Com type wrappers.Com type wrappers.]

#include <comet\datetime.h>

List of all members.

Constructors.

Attach to various system date/time types.

 datetime_t ()
 Constructor.
 datetime_t (DATE date)
 Constructor from raw DATE type.
 datetime_t (int year, int month, int day, int hours=-1, int minutes=0, int seconds=0, int milliseconds=0)
 Construct from date/time components.
 datetime_t (dt_invalid_t)
 Initialise as invalid.
 datetime_t (dt_null_t)
 Initialise as null.
 datetime_t (dt_zero_t)
 Initialise as zero.
 datetime_t (const SYSTEMTIME &systimeSrc)
 Construct from a SYSTEMTIME.
 datetime_t (const SYSTEMTIME &systimeSrc, utc_convert_mode utcMode, tz_bias_mode biasMode=tbm_use_local_date, const datetime_t &conversionTime=datetime_t())
 Construct from a SYSTEMTIME.
 datetime_t (const FILETIME &filetimeSrc, utc_convert_mode utcMode=ucm_none, tz_bias_mode biasMode=tbm_use_local_date, const datetime_t &conversionTime=datetime_t())
 Construct from a FILETIME.
 datetime_t (time_t timeSrc, utc_convert_mode utcMode=ucm_utc_to_local, tz_bias_mode biasMode=tbm_use_local_date, const datetime_t &conversionTime=datetime_t())
 Construct from time_t.
 datetime_t (const datetime_t &date)
 Copy constructor.
datetime_t get_null ()
 Get a 'NULL' datetime.
datetime_t get_zero ()
 Get a 'zero' datetime.

Public Types

enum  utc_convert_mode { ucm_none, ucm_local_to_utc, ucm_utc_to_local }
enum  tz_bias_mode { tbm_use_local_date, tbm_use_utc_date, tbm_force_standard, tbm_force_summer }
 Describe how to get the timezone bias. More...
enum  day_of_week {
  dow_sun = 0, dow_mon, dow_tue, dow_wed,
  dow_thu, dow_fri, dow_sat
}
 Day-of-week enumeration.
enum  format_flags {
  ff_default = 0, ff_system_locale = LOCALE_NOUSEROVERRIDE, ff_hijri = VAR_CALENDAR_HIJRI, ff_thai = 0x10,
  ff_gregorian = 0x20, ff_four_digits = VAR_FOURDIGITYEARS, ff_time_only = VAR_TIMEVALUEONLY, ff_date_only = VAR_DATEVALUEONLY
}
 Flags for formatting. More...

Public Member Functions

datetime_tadd_months (int inc_months)
datetime_tadd_years (int inc_years)
 Add specified number of years.
void split_date (int *year, int *month, int *day) const
 Return year/month/day values.
void split_time (int *hours, int *minutes, int *seconds, int *milliseconds=NULL) const
 Return hours/minutes/second values.
void split (int *year, int *month, int *day, int *hours, int *minutes, int *seconds, int *milliseconds=NULL)
 Return date/time split up.
bool invalid () const
 return true if the date is marked 'invalid'.
bool null () const
 return true if the date is marked 'null'
bool zero () const
 return true if date is zero
bool valid () const
bool good () const
 Return true if the date is usable.
bool set_date (int year, int month, int day)
bool set_time (int hours, int minutes, int seconds, int milliseconds=0)
bool set_date_time (int year, int month, int day, int hours, int minutes, int seconds, int milliseconds=0)
datetime_tparse (const bstr_t &val, format_flags flags=ff_default, LCID locale=LOCALE_USER_DEFAULT)
double as_sortable_double () const
datetime_t local_to_utc (tz_bias_mode biasMode=tbm_use_local_date, datetime_t asOfDate=datetime_t())
datetime_t utc_to_local (tz_bias_mode biasMode=tbm_use_local_date, datetime_t asOfDate=datetime_t())
bool to_systemtime (SYSTEMTIME *sysTime)
bool from_systemtime (const SYSTEMTIME &src)
bool from_systemtime (const SYSTEMTIME &src, utc_convert_mode utcMode, tz_bias_mode biasMode=tbm_use_local_date, const datetime_t &conversionTime=datetime_t())
bool from_filetime (const FILETIME &src)
bool from_filetime (const FILETIME &src, utc_convert_mode utcMode, tz_bias_mode biasMode=tbm_use_local_date, const datetime_t &conversionTime=datetime_t())
bool to_filetime (FILETIME *filetime)
bool from_tm (const struct tm &tm_time)
bool from_tm (const struct tm &tm_time, utc_convert_mode utcMode, tz_bias_mode biasMode=tbm_use_local_date, datetime_t conversionTime=datetime_t())
bool from_unixtime (time_t val)
bool from_unixtime (time_t val, utc_convert_mode utcMode=ucm_utc_to_local, tz_bias_mode biasMode=tbm_use_local_date, const datetime_t &conversionTime=datetime_t())
bool to_unixtime (time_t *val, utc_convert_mode utcMode=ucm_local_to_utc, tz_bias_mode biasMode=tbm_use_local_date, const datetime_t &conversionTime=datetime_t())
bstr_t format (format_flags flags=ff_default, LCID locale=LOCALE_USER_DEFAULT) const
template<typename CHAR> std::basic_string< CHAR > format (const std::basic_string< CHAR > &fmt) const
template<typename CHAR> std::basic_string< CHAR > format (const CHAR *fmt) const
DATE detach ()
 Detach the raw date from the class.
Access date/time parts.
int year () const
 Year.
int month () const
 Month of year (1-based).
int day () const
 Day of month (1-based).
int hour () const
 Hour part of time (0-based) ???
int minute () const
 Minute part of time (0-based).
int second () const
 Second.
int millisecond () const
 Milliseconds.
day_of_week dow () const
 The day of week.
int year_day () const
 Day of the year (0 -based).
int days_in_month ()
 Days in the month;.
Assignment operators
datetime_toperator= (const datetime_t &date)
datetime_toperator= (DATE date)
Comparison operators
bool operator== (const datetime_t &date) const
bool operator!= (const datetime_t &date) const
bool operator< (const datetime_t &date) const
bool operator> (const datetime_t &date) const
bool operator<= (const datetime_t &date) const
bool operator>= (const datetime_t &date) const
bool operator== (dt_invalid_t) const
bool operator!= (dt_invalid_t) const
bool operator== (dt_zero_t) const
bool operator!= (dt_zero_t) const
bool operator== (dt_null_t) const
bool operator!= (dt_null_t) const
Arithmetic operators
datetime_t operator+ (const timeperiod_t &dateSpan) const
datetime_t operator- (const timeperiod_t &dateSpan) const
datetime_toperator+= (const timeperiod_t &dateSpan)
datetime_toperator-= (const timeperiod_t &dateSpan)
timeperiod_t operator- (const datetime_t &date) const
datetime_toperator++ ()
datetime_t operator++ (int)
datetime_toperator-- ()
datetime_t operator-- (int)
Accessor methods
DATE get () const
DATE in () const
DATE * in_ptr () const
DATE * out ()
DATE * inout ()

Static Public Member Functions

const datetime_tcreate_const_reference (const DATE &s) throw ()
 Create a const reference.
datetime_tcreate_reference (DATE &s) throw ()
 Create a non-const reference.
datetime_t now ()
 Return the current time.
datetime_t now_utc ()
 Return the current utc time.
int days_in_month (int year, int month)
long local_timezone_bias (datetime_t dt, tz_bias_mode biasMode)
DATE detach (datetime_t &dt)
 Detach the raw date from the class.

Static Protected Member Functions

bool tz_on_or_after_in_year (SYSTEMTIME testST, SYSTEMTIME tziST)
void tz_convert_relative_dow_to_absolute (const SYSTEMTIME &testST, const SYSTEMTIME &tziST, SYSTEMTIME *absST)

Friends

std::basic_ostream< char > & operator<< (std::basic_ostream< char > &os, const datetime_t &val)
 Stream operator.
std::basic_ostream< wchar_t > & operator<< (std::basic_ostream< wchar_t > &os, const datetime_t &val)
 Stream operator.


Detailed Description

Wrapper for DATE. DATE/TIME Represented as days + fraction of days.


Member Enumeration Documentation

enum comet::datetime_t::format_flags
 

Flags for formatting.

Enumeration values:
ff_default  Default formatting.
ff_system_locale  Use system locale.
ff_hijri  Use HIJRI calendar.
ff_gregorian  Use thai calendar.
ff_four_digits  Four digits for years.
ff_time_only  Only output time.
ff_date_only  Only output date.

enum comet::datetime_t::tz_bias_mode
 

Describe how to get the timezone bias.

Enumeration values:
tbm_use_local_date  Use 'asOfDate' as a local date/time.
tbm_use_utc_date  Use 'asOfDate' as a utc date/time.
tbm_force_standard  Use standard-timezone offset.
tbm_force_summer  Use summer-timezone offset.

enum comet::datetime_t::utc_convert_mode
 

UTC/Local conversion mode.

Enumeration values:
ucm_none  No conversion.
ucm_local_to_utc  Convert from local to utc.
ucm_utc_to_local  Convert from utc to local.


Constructor & Destructor Documentation

comet::datetime_t::datetime_t int  year,
int  month,
int  day,
int  hours = -1,
int  minutes = 0,
int  seconds = 0,
int  milliseconds = 0
[inline, explicit]
 

Construct from date/time components.

If conversion fails, an valid() will return false.

comet::datetime_t::datetime_t const SYSTEMTIME &  systimeSrc  )  [inline, explicit]
 

Construct from a SYSTEMTIME.

Defaults to no conversion!

See also:
from_systemtime to_systemtime

comet::datetime_t::datetime_t const SYSTEMTIME &  systimeSrc,
utc_convert_mode  utcMode,
tz_bias_mode  biasMode = tbm_use_local_date,
const datetime_t conversionTime = datetime_t()
[inline, explicit]
 

Construct from a SYSTEMTIME.

Parameters:
systimeSrc System time being converted.
utcMode Timezone conversion mode.
biasMode Specify how to calculate whether the local time is daylight/standard time.
conversionTime Override the date to use for calculating daylight/standard time.

comet::datetime_t::datetime_t const FILETIME &  filetimeSrc,
utc_convert_mode  utcMode = ucm_none,
tz_bias_mode  biasMode = tbm_use_local_date,
const datetime_t conversionTime = datetime_t()
[inline, explicit]
 

Construct from a FILETIME.

Defaults to no conversion. FILETIME values are a tricky beast. FILETIMEs on FAT are local, as are ZIP files (mostly). On shares and NTFS, they are UTC.

Parameters:
filetimeSrc FileTime being converted.
utcMode Timezone conversion mode.
biasMode Specify how to calculate whether the local time is daylight/standard time.
conversionTime Override the date to use for calculating daylight/standard time.
See also:
from_filetime to_filetime

comet::datetime_t::datetime_t time_t  timeSrc,
utc_convert_mode  utcMode = ucm_utc_to_local,
tz_bias_mode  biasMode = tbm_use_local_date,
const datetime_t conversionTime = datetime_t()
[inline, explicit]
 

Construct from time_t.

See also:
from_unixtime to_unixtime Defaults to conversion from utc to local time as time_t is in UTC.
Parameters:
timeSrc time_t being converted.
utcMode Timezone conversion mode.
biasMode Specify how to calculate whether the local time is daylight/standard time.
conversionTime Override the date to use for calculating daylight/standard time.


Member Function Documentation

datetime_t& comet::datetime_t::add_months int  inc_months  )  [inline]
 

Add specified number of months. If the day is not valid (ie 1 month from 31 December) an exception will be thrown.

Todo:
Add an enum to be more smart about this.

double comet::datetime_t::as_sortable_double  )  const [inline]
 

Return a double that is sortable / can be subtracted. Dates before 12/30/1899 will not sort propperly.

template<typename CHAR>
std::basic_string<CHAR> comet::datetime_t::format const CHAR *  fmt  )  const [inline]
 

Format datetime_t as basic_string.

Parameters:
fmt See system documentation for strftime for details.

template<typename CHAR>
std::basic_string<CHAR> comet::datetime_t::format const std::basic_string< CHAR > &  fmt  )  const [inline]
 

Format datetime_t as basic_string.

Parameters:
fmt See system documentation for strftime for details.

bstr_t comet::datetime_t::format format_flags  flags = ff_default,
LCID  locale = LOCALE_USER_DEFAULT
const [inline]
 

Format datetime_t as bstr.

Parameters:
flags Format (can be or-ed). All format_flags are valid.
locale Locale ID (default to User Default.

bool comet::datetime_t::from_filetime const FILETIME &  src,
utc_convert_mode  utcMode,
tz_bias_mode  biasMode = tbm_use_local_date,
const datetime_t conversionTime = datetime_t()
[inline]
 

Convert from a FILETIME struct.

Parameters:
src FILETIME being converted.
utcMode Timezone conversion mode.
biasMode Specify how to calculate whether the local time is daylight/standard time.
conversionTime Override the date to use for calculating daylight/standard time.

bool comet::datetime_t::from_filetime const FILETIME &  src  )  [inline]
 

Convert from a FILETIME struct.

bool comet::datetime_t::from_systemtime const SYSTEMTIME &  src,
utc_convert_mode  utcMode,
tz_bias_mode  biasMode = tbm_use_local_date,
const datetime_t conversionTime = datetime_t()
[inline]
 

Convert from a SYSTIME struct.

Parameters:
src SYSTEMTIME being converted.
utcMode Timezone conversion mode.
biasMode Specify how to calculate whether the local time is daylight/standard time.
conversionTime Override the date to use for calculating daylight/standard time.

bool comet::datetime_t::from_systemtime const SYSTEMTIME &  src  )  [inline]
 

Convert from a SYSTIME struct.

bool comet::datetime_t::from_tm const struct tm &  tm_time,
utc_convert_mode  utcMode,
tz_bias_mode  biasMode = tbm_use_local_date,
datetime_t  conversionTime = datetime_t()
[inline]
 

Convert from a tm struct.

Parameters:
tm_time 'tm' struct being converted.
utcMode Timezone conversion mode.
biasMode Specify how to calculate whether the local time is daylight/standard time.
conversionTime Override the date to use for calculating daylight/standard time.

bool comet::datetime_t::from_tm const struct tm &  tm_time  )  [inline]
 

Convert from a tm struct.

bool comet::datetime_t::from_unixtime time_t  val,
utc_convert_mode  utcMode = ucm_utc_to_local,
tz_bias_mode  biasMode = tbm_use_local_date,
const datetime_t conversionTime = datetime_t()
[inline]
 

Convert from a time_t value.

Parameters:
val Value to convert.
utcMode Timezone conversion mode.
biasMode Specify how to calculate whether the local time is daylight/standard time.
conversionTime Override the date to use for calculating daylight/standard time.

bool comet::datetime_t::from_unixtime time_t  val  )  [inline]
 

Convert from a time_t value.

long comet::datetime_t::local_timezone_bias datetime_t  dt,
tz_bias_mode  biasMode
[inline, static]
 

Calculates the local time Bias (to subtract from UTC), using the timezone rules for this date. This "as of" date may be the current time or possibly the modification or creation date of an enclosing ZIP file. It must be specified if this "as of" date is in UTC or not.

datetime_t comet::datetime_t::local_to_utc tz_bias_mode  biasMode = tbm_use_local_date,
datetime_t  asOfDate = datetime_t()
[inline]
 

Convert a local time to UTC. Takes a local time (like that inside a ZIP file, or on a FAT file system) and converts it to UTC, using the timezone rules in effect as of the date specified. Typically the "as of" date is specified as the modification or creation date of the ZIP file, or left missing to default to the given local date. It is also possible to specify if the "as of" date is in UTC or not. If missing, it defaults to false.

datetime_t& comet::datetime_t::parse const bstr_t val,
format_flags  flags = ff_default,
LCID  locale = LOCALE_USER_DEFAULT
[inline]
 

Parse bstring to a datetime_t.

Parameters:
val String to parse.
flags valid format_flags are: ff_default, ff_system_locale, ff_hijri, ff_time_only, ff_date_only
locale Locale to use. Default locale is the user default.

bool comet::datetime_t::set_date int  year,
int  month,
int  day
[inline]
 

Set date part as year/month/day.

Parameters:
year Year (from year 0 - as in 2000).
month Month of year (1-based).
day Day of month (1-based).
Return values:
true Successfully set date.
false Conversion unsuccessful - date not set.

bool comet::datetime_t::set_date_time int  year,
int  month,
int  day,
int  hours,
int  minutes,
int  seconds,
int  milliseconds = 0
[inline]
 

Set both date and time.

Parameters:
year Year (from year 0 - as in 2000).
month Month of year (1-based).
day Day of month (1-based).
hours As in a 24-hour clock.
minutes Minutes past the hour.
seconds Seconds past the minute.
milliseconds Milliseconds past the second.
Return values:
true Successfully set date/time.
false Conversion unsuccessful - date/time not set.

bool comet::datetime_t::set_time int  hours,
int  minutes,
int  seconds,
int  milliseconds = 0
[inline]
 

Set time part as hours/minutes/seconds.

Parameters:
hours As in a 24-hour clock.
minutes Minutes past the hour.
seconds Seconds past the minute.
milliseconds Milliseconds past the second.
Return values:
true Successfully set time.
false Conversion unsuccessful - time not set.

bool comet::datetime_t::to_filetime FILETIME *  filetime  )  [inline]
 

Convert to a FILETIME struct.

bool comet::datetime_t::to_systemtime SYSTEMTIME *  sysTime  )  [inline]
 

Convert to SYSTEMTIME struct.

bool comet::datetime_t::to_unixtime time_t *  val,
utc_convert_mode  utcMode = ucm_local_to_utc,
tz_bias_mode  biasMode = tbm_use_local_date,
const datetime_t conversionTime = datetime_t()
[inline]
 

Convert to a time_t value.

Parameters:
val time-t value output.
utcMode Timezone conversion mode.
biasMode Specify how to calculate whether the local time is daylight/standard time.
conversionTime Override the date to use for calculating daylight/standard time.

bool comet::datetime_t::tz_on_or_after_in_year SYSTEMTIME  testST,
SYSTEMTIME  tziST
[inline, static, protected]
 

Compares two SYSTEMTIME values to decide if the second is after (or on) the first. If the year is supplied, the two dates are assumed static, otherwise it computes the proper day-of-week instance (like last Sunday in October) for the specified test year. See the encoding rules documented with TIME_ZONE_INFORMATION

datetime_t comet::datetime_t::utc_to_local tz_bias_mode  biasMode = tbm_use_local_date,
datetime_t  asOfDate = datetime_t()
[inline]
 

Convert a UTC time to a local time. Takes a UTC time (like that on and NTFS file system) and converts it to local time, using the timezone rules in effect as of the date specified. Typically the "as of" date is specified as the current time or possibly the modification or creation date of an enclosing ZIP file, or left missing to default to the given UTC date. It is also possible to specify if the "as of" date is in UTC or not. If missing, if the "as of" date is not specified, it defaults to TRUE (since the "as of" date IS UTC), otherwise it defaults to false.

bool comet::datetime_t::valid  )  const [inline]
 

return true if the date is not marked 'invalid'.

Deprecated:


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