sptk2 logo
SPTK Home Page

sptk::CDateTime Class Reference
[Utility Classes]

Date and Time value. More...

#include <CDateTime.h>

List of all members.

Public Member Functions

 CDateTime (int16_t y, int16_t m, int16_t d, int16_t h=0, int16_t mm=0, int16_t s=0)
 Constructor.
 CDateTime (const char *dateStr)
 Constructor.
 CDateTime (const CDateTime &dt)
 Copy constructor.
 CDateTime (const double dt=0)
 Constructor.
 operator double () const
 Conversion to double.
void operator= (const CDateTime &date)
 Assignment.
void operator= (const char *dat)
 Assignment.
CDateTime operator+ (CDateTime &dt)
 Addition, another CDateTime.
CDateTime operator- (CDateTime &dt)
 Substruction, another CDateTime.
CDateTimeoperator+= (CDateTime &dt)
 Increment by another CDateTime.
CDateTimeoperator-= (CDateTime &dt)
 Decrement by another CDateTime.
CDateTimeoperator++ ()
 Increment by day, prefix.
CDateTimeoperator++ (int)
 Increment by day, postfix.
CDateTimeoperator-- ()
 Decrement by day, prefix.
CDateTimeoperator-- (int)
 Decrement by day, postfix.
void formatDate (char *str) const
 Print the date into str.
void formatTime (char *str, bool ampm=true, bool showSeconds=false) const
 Print the date into str.
int16_t daysInMonth () const
 Reports the number of days in the month in this date (1..31).
int16_t dayOfWeek (void) const
 Reports the day of the week in this date (1..7).
int16_t dayOfYear () const
 Reports the day since the beginning of the year in this date.
std::string dayOfWeekName (void) const
 Reports the day of the week name in this date ('Sunday'..'Saturday').
std::string monthName () const
 Reports the month name in this date ('Sunday'..'Saturday').
uint32_t date () const
 Reports the date as an integer.
int16_t day () const
 Reports the day of month (1..31).
int16_t month () const
 Reports the month number (1..12).
int16_t year () const
 Reports the year.
std::string dateString () const
 Returns date as a string.
std::string timeString (bool showSeconds=false) const
 Returns time as a string.
 operator std::string () const
 Returns date and time as a string.
void decodeDate (int16_t *y, int16_t *m, int16_t *d) const
 Decodes date into y,m,d.
void decodeTime (int16_t *h, int16_t *m, int16_t *s, int16_t *ms) const
 Decodes time into h,m,s,ms.

Static Public Member Functions

static void Now (CDateTime dt)
 Set the current date and time for this program only.
static CDateTime System ()
 Reports the system date and time.
static CDateTime Now ()
 Reports the current date and time.
static CDateTime Date ()
 Reports the current date.
static CDateTime Time ()
 Reports the current time.
static uint32_t TimeOfDayMs ()
 Reports the current time of day in milliseconds.
static CDateTime convertCTime (const time_t tt)
 Converts C time into CDateTime.
static bool time24Mode ()
 Returns system's time mode.
static void time24Mode (bool t24mode)
 Sets system's time mode.

Static Public Attributes

static char dateFormat [32]
 System's date format.
static char fullTimeFormat [32]
 System's time format.
static char shortTimeFormat [32]
 System's time format.
static char datePartsOrder [4]
 System's date parts order.
static char dateSeparator
 System's date separator.
static char timeSeparator
 System's time separator.
static std::string weekDayNames [7]
 The locale-defined weekday names.
static std::string monthNames [12]
 The locale-defined weekday names.
static std::string timeZoneName
 Time zone abbbreviastion.
static int timeZoneOffset
 Time zone offset from GMT in hours.

Static Protected Member Functions

static void decodeDate (const double dt, int16_t &y, int16_t &m, int16_t &d)
 Internal decode date operation into y,m,d.
static void decodeTime (const double dt, int16_t &h, int16_t &m, int16_t &s, int16_t &ms)
 Internal decode time operation into h,m,s,ms.
static void encodeDate (double &dt, int16_t y=0, int16_t m=0, int16_t d=0)
 Internal encode date operation from y,m,d.
static void encodeDate (double &dt, const char *dat)
 Internal encode date operation from string.
static void encodeTime (double &dt, int16_t h=0, int16_t m=0, int16_t s=0, int16_t ms=0)
 Internal encode timee operation from h,m,s,ms.
static void encodeTime (double &dt, const char *tim)
 Internal encode timee operation from string.
static int isLeapYear (const int16_t year)
 Returns true for the leap year.

Protected Attributes

double m_dateTime
 Actual date and time value.

Static Protected Attributes

static double m_dateTimeOffset
static bool m_time24Mode
 System's time mode.

Friends

class CDateTimeFormat


Detailed Description

Date and Time value.

Represents the date and time value. This value is stored as a floating point number. Allows to synchronize the Now() time with the external date/time, without affecting the local host system time.


Constructor & Destructor Documentation

sptk::CDateTime::CDateTime ( int16_t  y,
int16_t  m,
int16_t  d,
int16_t  h = 0,
int16_t  mm = 0,
int16_t  s = 0 
)

Constructor.

Parameters:
y int16_t, year
m int16_t, month
d int16_t, day
h int16_t, hour
mm int16_t, minute
s int16_t, second

sptk::CDateTime::CDateTime ( const char *  dateStr  ) 

Constructor.

Parameters:
dateStr const char *, date string

sptk::CDateTime::CDateTime ( const double  dt = 0  ) 

Constructor.

Parameters:
dt double, floating point date and time value


Member Function Documentation

static void sptk::CDateTime::Now ( CDateTime  dt  )  [static]

Set the current date and time for this program only.

The system time is not affected. Useful for synchronization between different hosts' programs.

static uint32_t sptk::CDateTime::TimeOfDayMs (  )  [static]

Reports the current time of day in milliseconds.

This is fast method to get a time of day without considering dateTimeOffset. It's useful for measuring short time intervals (shorter than one day, anyway).


Member Data Documentation

double sptk::CDateTime::m_dateTimeOffset [static, protected]

The offset from current' system time for synchronization with outside system


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

Mon Mar 5 11:55:56 2012: SPTK 3.5.7