DATETIME Class Reference

Container for date/time. More...

#include <mi32/datetime.h>

List of all members.

Public Types

enum  FORMAT {
  FORMAT_ISO8601_Basic = 0, FORMAT_ISO8601_Extended = 1, FORMAT_XML_dateTime = 2, FORMAT_XML_date = 3,
  FORMAT_XML_time = 4, FORMAT_RFC822 = 5, FORMAT_Simple = 6, FORMAT_YYYYMMDD_HHMMSS = 7,
  FORMAT_Job = FORMAT_YYYYMMDD_HHMMSS
}
enum  TIME { TIME_Uninitialized = 0, TIME_CurrentLocal = 1, TIME_CurrentUTC = 2 }

Public Member Functions

 DATETIME (time_t value)
 DATETIME (const struct tm &rhs, bool bIsLocal)
 DATETIME (const RVCDATETIME &rhs)
 DATETIME (int year, int month, int day, int hour, int min, int sec, bool bIsLocal)
 DATETIME (int year, int month, int day)
 DATETIME (TIME value)
 DATETIME (const DATETIME &rhs)
 DATETIME ()
 ~DATETIME ()
void Clear ()
void ConvertToLocal ()
void ConvertToUTC ()
void Get (RVCDATETIME &dt) const
void Get (struct tm &tm, bool bLocal=false) const
INT32 GetDateJulian () const
double GetDateTimeJulian () const
INT32 GetDateYYYYMMDD () const
UINT32 GetDayOfMonth () const
UINT32 GetDayOfWeek () const
UINT32 GetDayOfYear () const
MISTRING GetFormatted (FORMAT format, bool IncludeLocal) const
UINT32 GetHour () const
UINT32 GetMin () const
UINT32 GetMonth () const
UINT64 GetNanoTime () const
UINT32 GetSec () const
UINT32 GetTimeOfDay (bool bLocal) const
time_t GetTimeT () const
INT32 GetYear () const
bool IsLocalTime () const
bool IsSet () const
bool IsUTCTime () const
bool IsValid () const
bool operator!= (const DATETIME &rhs) const
bool operator< (const DATETIME &rhs) const
bool operator<= (const DATETIME &rhs) const
DATETIMEoperator= (DATETIME::TIME rhs)
DATETIMEoperator= (const time_t rhs)
DATETIMEoperator= (const RVCDATETIME &rhs)
DATETIMEoperator= (const DATETIME &rhs)
bool operator== (const DATETIME &rhs) const
bool operator> (const DATETIME &rhs) const
bool operator>= (const DATETIME &rhs) const
const MIUNICODESet (const MIUNICODE *str, const char *format="%c")
void Set (const RVCDATETIME &rhs)
void Set (const struct tm &rhs, bool bIsLocal)
void Set (const time_t rhs)
void SetBuild ()
void SetCurrent (bool bLocalTime=true)
void SetDate (INT32 year, UINT32 month, UINT32 day)
void SetDateJulian (INT32 juliandate)
void SetDateTimeJulian (double juliandate)
void SetDateYYYYMMDD (int yyyymmdd)
void SetFormatted (const MISTRING &dtstr, FORMAT format)
void SetNanoTime (UINT64 rhs)
void SetTimeOfDay (UINT32 SecondsSinceMidnight, bool bIsLocal)
void SetTimeOfDay (UINT32 hour, UINT32 min, UINT32 sec, bool bIsLocal)
void StrfTime (MISTRING &str, const char *format, bool bLocal=true) const

Detailed Description

Container for date/time.

The date/time represented can be either UTC (a.k.a. GMT) or the local time zone.


Member Enumeration Documentation

Enumerator:
FORMAT_ISO8601_Basic 

Format is YYYYMMDDTHHMMSS.S+ZZ where 'T' is the separator, and ZZ is the time zone offset.

FORMAT_ISO8601_Extended 

Format is YYYY-MM-DDTHH:MM:SS.S+ZZ:ZZ where 'T' is the separator, and ZZ is the time zone offset.

FORMAT_XML_dateTime 

Format is defined by http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/datatypes.html#dateTime.

FORMAT_XML_date 

Format is defined by http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/datatypes.html#date.

FORMAT_XML_time 

Format is defined by http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/datatypes.html#time.

FORMAT_RFC822 

Format is dd mm yy hh:mm:ss zzz (SMTP format).

FORMAT_Simple 

Format is YYYY-MM-DD HH:MM:SS with no time zone specified.

FORMAT_YYYYMMDD_HHMMSS 

Format is YYYYMMDD_HHMMSS for job files.

FORMAT_Job 

Format is YYYYMMDD_HHMMSS for job files.

Enumerator:
TIME_Uninitialized 
TIME_CurrentLocal 
TIME_CurrentUTC 

Constructor & Destructor Documentation

DATETIME::DATETIME (  ) 

Default constructor.

DATETIME::DATETIME ( const DATETIME rhs  ) 

Copy constructor.

DATETIME::DATETIME ( TIME  value  ) 

Constructor for a specific time.

DATETIME::DATETIME ( int  year,
int  month,
int  day 
)

Construct for a given date.

Note, this one doesn't have the IsLocal parameter since no time is set.

Parameters:
year Year, must include centurary
month Month (Jan == 1)
day Day of month (1 - 31)
DATETIME::DATETIME ( int  year,
int  month,
int  day,
int  hour,
int  min,
int  sec,
bool  bIsLocal 
)

Construct for a given date/time.

Parameters:
year Year, must include centurary
month Month (Jan == 1)
day Day of month (1 - 31)
bIsLocal True if time is local, false if UTC
DATETIME::DATETIME ( const RVCDATETIME rhs  ) 

Construct from an RVCDATETIME.

Note: RVCDATETIMEs are always "local" time

DATETIME::DATETIME ( const struct tm &  rhs,
bool  bIsLocal 
)

construct from a struct tm

Parameters:
bIsLocal True if time is local, false if UTC
DATETIME::DATETIME ( time_t  value  )  [explicit]

construct from a time_t.

Note, by definition, a time_t is always supposed to be UTC,

DATETIME::~DATETIME (  ) 

Destructor.


Member Function Documentation

void DATETIME::Clear (  ) 

Clear.

void DATETIME::ConvertToLocal (  ) 

Change internal representation from UTC to local time zone.

Does nothing if internal representation is already local.

void DATETIME::ConvertToUTC (  ) 

Change internal representation local time zone to UTC.

Does nothing if internal representation is already UTC.

void DATETIME::Get ( RVCDATETIME dt  )  const

Get the date/time as an RVCDATETIME.

Sets the count field to 0. RVCDATETIMEs are always be local time for historical reasons

void DATETIME::Get ( struct tm &  tm,
bool  bLocal = false 
) const

Get the date/time as a (struct tm).

Note, the tm_wday and tm_yday fields are not guarenteed to be filled out.

Parameters:
bLocal true to get local time, false to get UTC
INT32 DATETIME::GetDateJulian (  )  const

Return the Julian date.

double DATETIME::GetDateTimeJulian (  )  const

Return the Julian date.

Returns Julian date as a double with the time represented as a fraction of a day

INT32 DATETIME::GetDateYYYYMMDD (  )  const

Get the date as an integer in YYYYMMDD format.

This is the form RVC database DBFIELDTYPE_Date uses.

UINT32 DATETIME::GetDayOfMonth (  )  const

Get the day of the month (1 - 31).

UINT32 DATETIME::GetDayOfWeek (  )  const

Get day of the week (1 = Sunday, 7 = Saturday).

UINT32 DATETIME::GetDayOfYear (  )  const

Returns the day of the year (1 - 366).

MISTRING DATETIME::GetFormatted ( FORMAT  format,
bool  IncludeLocal 
) const

Get the string representation of the date / time according to the standard 'format' specified.

The return value can be used in a MISTRING << operation. Return the string representation of the date / time.

Parameters:
IncludeLocal Append local time zone information if the 'format' supports it
UINT32 DATETIME::GetHour (  )  const

Get the Hour value of the time.

UINT32 DATETIME::GetMin (  )  const

Get the Minutes value of the time.

UINT32 DATETIME::GetMonth (  )  const

Get the month number (1 - 12).

UINT64 DATETIME::GetNanoTime (  )  const

Return the date given a 100 nanosecond interval from 1-jan-1601 (Windows FILETIME structure) This is the form RVC database DBFIELDTYPE_DateTime uses.

UINT32 DATETIME::GetSec (  )  const

Get the Seconds value of the time.

UINT32 DATETIME::GetTimeOfDay ( bool  bLocal  )  const

Get time in seconds past midnight.

Parameters:
bLocal true to get local time, false for UTC
time_t DATETIME::GetTimeT (  )  const

Get the current value as a time_t.

time_t values are always UTC

INT32 DATETIME::GetYear (  )  const

Get the year, including century.

bool DATETIME::IsLocalTime (  )  const

Returns true if the time represented by the local time zone.

bool DATETIME::IsSet (  )  const

Determine if value has been set.

bool DATETIME::IsUTCTime (  )  const

Returns true if the time represented by the class is in UTC.

Note, this is just !IsLocalTime()

bool DATETIME::IsValid (  )  const

Determine if contains valid date and time.

bool DATETIME::operator!= ( const DATETIME rhs  )  const
bool DATETIME::operator< ( const DATETIME rhs  )  const
bool DATETIME::operator<= ( const DATETIME rhs  )  const
DATETIME& DATETIME::operator= ( DATETIME::TIME  rhs  ) 

assignment from time_t (assumed to be UTC (a.k.a. GMT))

DATETIME& DATETIME::operator= ( const time_t  rhs  ) 

assignment from time_t (assumed to be UTC (a.k.a. GMT))

DATETIME& DATETIME::operator= ( const RVCDATETIME rhs  ) 

Assignment from an RVCDATETIME.

DATETIME& DATETIME::operator= ( const DATETIME rhs  ) 

Assignment operator from DATETIME.

bool DATETIME::operator== ( const DATETIME rhs  )  const
bool DATETIME::operator> ( const DATETIME rhs  )  const
bool DATETIME::operator>= ( const DATETIME rhs  )  const
const MIUNICODE* DATETIME::Set ( const MIUNICODE str,
const char *  format = "%c" 
)

Set the time from a string.

See the man page for strptime() on most Unix systems for details

Returns:
NULL if the conversion fails, else returns a pointer to the first character in the input string which is not part of a date/time string.
Parameters:
format See StrfTime
void DATETIME::Set ( const RVCDATETIME rhs  ) 

Set value from an RVCDATETIME.

Note, RVCDATETIMEs are stored as local, not UTC

void DATETIME::Set ( const struct tm &  rhs,
bool  bIsLocal 
)

Set from (struct tm).

Parameters:
bIsLocal True if time is local, false if UTC
void DATETIME::Set ( const time_t  rhs  ) 

Set from time_t.

time_t values should always be UTC

void DATETIME::SetBuild (  ) 

Set to 'build' date. Time will be 12:00 (noon) UTC.

void DATETIME::SetCurrent ( bool  bLocalTime = true  ) 

Set to the current date/time.

Parameters:
bLocalTime True to set to local time, false for UTC
void DATETIME::SetDate ( INT32  year,
UINT32  month,
UINT32  day 
)

Set the date (Leaves the time alone).

Parameters:
year must include century
month Jan == 1
day 1 - 31
void DATETIME::SetDateJulian ( INT32  juliandate  ) 

Set the date given a julian date.

Leaves time fields alone.

void DATETIME::SetDateTimeJulian ( double  juliandate  ) 

Set the date given a julian date.

time is set from the fractional part of the double

void DATETIME::SetDateYYYYMMDD ( int  yyyymmdd  ) 

Set date given date in YYYYMMDD format Leaves time fields alone.

void DATETIME::SetFormatted ( const MISTRING dtstr,
FORMAT  format 
)

Set 'this' from the string representation of the date / time according to the standard 'format' specified.

The time value obtained from the formatted string will be converted to UTC time if the string includes the time zone offset.

void DATETIME::SetNanoTime ( UINT64  rhs  ) 

Set the date given a 100 nanosecond interval from 1-jan-1601 (Windows FILETIME structure) This is the form RVC database DBFIELDTYPE_DateTime uses Not called Set() due to ambiguity.

void DATETIME::SetTimeOfDay ( UINT32  SecondsSinceMidnight,
bool  bIsLocal 
)

Set the time in seconds since midnight.

Leaves date fields alone.

Parameters:
bIsLocal True if time is local, false if UTC
void DATETIME::SetTimeOfDay ( UINT32  hour,
UINT32  min,
UINT32  sec,
bool  bIsLocal 
)

Set the time in hours, minutes and seconds.

Leaves date fields alone.

Parameters:
bIsLocal True if time is local, false if UTC
void DATETIME::StrfTime ( MISTRING str,
const char *  format,
bool  bLocal = true 
) const

Print a time/date to a MISTRING using strftime() formatting.

Does not clear the MISTRING first. The time/date string is appended to the current contents.

The format string must only use punctuation, whitespace and the following things...

  • %% A literal "%" character.
  • a The abbreviated weekday according to the current locale
  • b The abbreviated month name according to the current locale
  • B The full month name according to the current locale
  • c The preferred date and time representation for the current locale.
  • C The century number (year/100) as a 2-digit integer
  • d The day of the month as a decimal number (01 - 31)
  • e Like d, but leading zero is replaced by a space.
  • h Same as b
  • H The hour as a decimal number using a 24-hour clock (00 - 23)
  • I The hour as a decimal number using a 12-hour clock (00 - 12)
  • j The day of the year as a decimal number (001 - 366)
  • k The hour (24-hour clock) Single digits preceded by a blank
  • l The hour (12-hour clock) Single digits preceded by a blank
  • m The month as a decimal number (01 - 12)
  • M The minute as a decimal number (00 - 59)
  • n A newline character (same as
    )
  • p Either "AM" or "PM" in the current locale (noon=="PM", midnight=="AM")
  • P Either "am" or "pm" in the current locale. Yes, p is uppercase and P is lowercase. That's POSIX's fault!
  • r The time in AM or PM notation. In POSIX locale, this is "%I:%M:%S %p"
  • r The time in 24-hour notation. In POSIX locale, this is "%H:%M". For a version including seconds, see T
  • s The number of seconds since the Epoch (1970-01-01 00:00:00 UTC) except that on Macintoshes, the Epoch started in 1974.
  • S The seconds as a decimal number (00 - 59)
  • t A tab character
  • T The time in 24-hour notation. (H:M:S)
  • u The day of the week as a decimal (1 - 7, Monday == 1)
  • U The week number of the current year as a decimal number (00 - 53) starting with the first Sunday as the first day of week 01. See also V and W
  • V The ISO 8601:1988 week number of the current year (01 - 53) where week 1 is the first week that has at least 4 days in the current year and Monday is the first day of the week.
  • w The day of hte week as a decimal (0 - 6, Sunday == 0)
  • W The week number of the current year as a decimal number (00 - 53), starting with the first Monday as the first day of week 01
  • x The preferred date representation for the current locale without the time.
  • X The preferred time representation for the current locale without the date.
  • y The year as a decimal number without a century (00 - 99)
  • Y The year as a decimal number including the century
  • z The time-zone as hour offset from GMT. Required to emit RFC822-conformant dates.
  • Z The time-zone name or abbreviation
Parameters:
format See strftime() documentation for details
bLocal True to show local time, false for UTC

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

Generated on Sun Oct 7 21:33:18 2012 for TNTsdk 2012 by  doxygen 1.6.1