neic-glass3  1.4.6
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
glass3::util::Date Class Reference

time translation class More...

#include <date.h>

Collaboration diagram for glass3::util::Date:
Collaboration graph

Public Member Functions

 Date ()
 CDate default constructor. More...
 
 Date (double time)
 CDate advanced constructor. More...
 
 Date (unsigned int year, unsigned int month, unsigned int day, unsigned int hour, unsigned int minutes, double seconds)
 CDate advanced constructor. More...
 
 Date (std::string time)
 CDate advanced constructor. More...
 
 ~Date ()
 CDate destructor. More...
 
void clear ()
 CDate clear function. More...
 
bool initialize (double time)
 CDate initialize function. More...
 
bool initialize (unsigned int year, unsigned int month, unsigned int day, unsigned int hour, unsigned int minutes, double seconds)
 CDate alternate initialize function. More...
 
bool initialize (std::string time)
 CDate alternate initialize function. More...
 
unsigned int year ()
 Get the gregorian year. More...
 
unsigned int month ()
 Get the gregorian month. More...
 
unsigned int day ()
 Get the gregorian day. More...
 
unsigned int hour ()
 Get the gregorian hour. More...
 
unsigned int minute ()
 Get the gregorian minute. More...
 
double seconds ()
 Get the gregorian seconds. More...
 
double time ()
 Get the Gregorian seconds. More...
 
std::string date18 ()
 Calculate the 20 character date string. More...
 
std::string date20 ()
 Calculate the 18 character date string. More...
 
std::string ISO8601 ()
 Calculate the ISO8601 date string. More...
 
std::string dateTime ()
 Calculate the DateTime date string. More...
 
double decodeDateTime (std::string datetime)
 Decode the datetime format date string into Gregorian seconds. More...
 
double decodeISO8601Time (std::string iso8601)
 Decode the ISO8601 date string into Gregorian seconds. More...
 

Static Public Member Functions

static double now ()
 CDate current time function. More...
 
static std::string encodeDateTime (double t)
 Calculate (encode) the date time date string. More...
 
static std::string encodeISO8601Time (double t)
 Calculate (encode) the ISO8610 date string. More...
 
static std::string convertEpochTimeToISO8601 (double epochTime)
 Convert time from epoch time to ISO8601. More...
 
static std::string convertEpochTimeToISO8601 (std::time_t epochTime, double decimalSeconds=0)
 Convert time from epoch time to ISO8601. More...
 
static std::string convertDateTimeToISO8601 (const std::string &timeString)
 Convert time from date time format to ISO8601 format. More...
 
static double convertDateTimeToEpochTime (const std::string &timeString)
 Convert time from date time to epoch time. More...
 
static double convertISO8601ToEpochTime (const std::string &timeString)
 Convert time from ISO8601 time to epoch time. More...
 

Protected Attributes

unsigned int m_nYear
 An unsigned integer variable containing the gregorian year. More...
 
unsigned int m_nMonth
 An unsigned integer variable containing the gregorian month. More...
 
unsigned int m_nDay
 An unsigned integer variable containing the gregorian day. More...
 
unsigned int m_nHour
 An unsigned integer variable containing the gregorian hour. More...
 
unsigned int m_nMinute
 An unsigned integer variable containing the gregorian minute. More...
 
double m_dSeconds
 A double variable containing the gregorian seconds. More...
 
double m_dTime
 A double variable containing the Gregorian seconds. More...
 

Detailed Description

time translation class

The date class is a class that stores time/date information and supports converting time/ date information between various formats external (human) and internal (epoch time, ISO8601, etc.) storing date internally as a double containing Gregorian seconds.

Constructor & Destructor Documentation

glass3::util::Date::Date ( )

CDate default constructor.

The default constructor for the CDate class.

glass3::util::Date::Date ( double  time)
explicit

CDate advanced constructor.

An advanced constructor for the CDate class, initializes the class from a provided time in Gregorian seconds.

Parameters
time- A double value containing the time in Gregorian seconds
glass3::util::Date::Date ( unsigned int  year,
unsigned int  month,
unsigned int  day,
unsigned int  hour,
unsigned int  minutes,
double  seconds 
)

CDate advanced constructor.

An advanced constructor for the CDate class, initializes the class from a provided gregorian date/time.

Parameters
year- An unsigned integer value containing the year
month- An unsigned integer value containing the month
day- An unsigned integer value containing the day
hour- An unsigned integer value containing the hour
minutes- An unsigned integer value containing the minutes
seconds- A double value containing the seconds
glass3::util::Date::Date ( std::string  time)
explicit

CDate advanced constructor.

An advanced constructor for the CDate class, initializes the class from a provided time string.

Parameters
time- A string value containing the time
glass3::util::Date::~Date ( )

CDate destructor.

The destructor for the CDate class.

Member Function Documentation

void glass3::util::Date::clear ( )

CDate clear function.

CDate clear function

double glass3::util::Date::convertDateTimeToEpochTime ( const std::string &  timeString)
static

Convert time from date time to epoch time.

Convert the given DateTime time string in the format YYYYMMDDHHMMSS.SSS to an epoch time (seconds from 1970)

For more information on epoch time, see https://en.wikipedia.org/wiki/Unix_time

Parameters
timeString- A std::string containing the date time in the format YYYYMMDDHHMMSS.SSS
Returns
returns a double variable containing the epoch time (seconds from 1970)
std::string glass3::util::Date::convertDateTimeToISO8601 ( const std::string &  timeString)
static

Convert time from date time format to ISO8601 format.

Convert the given DateTime time string in the format YYYYMMDDHHMMSS.SSS to an ISO8601 time string in the format YYYY-MM-DDTHH:MM:SS.SSSZ

For more information on ISO8601, see https://en.wikipedia.org/wiki/ISO_8601

Parameters
timeString- A std::string containing the date time in the format YYYYMMDDHHMMSS.SS
Returns
returns a std::string containing the ISO8601 time string in the format YYYY-MM-DDTHH:MM:SS.SSSZ
std::string glass3::util::Date::convertEpochTimeToISO8601 ( double  epochTime)
static

Convert time from epoch time to ISO8601.

Convert the given epoch time (seconds from 1970) from decimal seconds to an ISO8601 time string in the format YYYY-MM-DDTHH:MM:SS.SSSZ

For more information on epoch time, see https://en.wikipedia.org/wiki/Unix_time

For more information on ISO8601, see https://en.wikipedia.org/wiki/ISO_8601

Parameters
epochTime- A double containing the epoch time (seconds from 1970)
Returns
returns a std::string containing the ISO8601 time string in the format YYYY-MM-DDTHH:MM:SS.SSSZ
std::string glass3::util::Date::convertEpochTimeToISO8601 ( std::time_t  epochTime,
double  decimalSeconds = 0 
)
static

Convert time from epoch time to ISO8601.

Convert the given epoch time (seconds from 1970) from decimal seconds to an ISO8601 time string

For more information on epoch time, see https://en.wikipedia.org/wiki/Unix_time

For more information on ISO8601, see https://en.wikipedia.org/wiki/ISO_8601

Parameters
epochTime- A time_t containing the epoch time (seconds from 1970)
decimalSeconds- A an optional double containing the decimal seconds, default is 0
Returns
returns a std::string containing the ISO8601 time string in the format YYYY-MM-DDTHH:MM:SS.SSSZ
double glass3::util::Date::convertISO8601ToEpochTime ( const std::string &  timeString)
static

Convert time from ISO8601 time to epoch time.

Convert the given ISO8601 string in the format YYYY-MM-DDTHH:MM:SS.SSSZ to an epoch time

For more information on epoch time, see https://en.wikipedia.org/wiki/Unix_time

For more information on ISO8601, see https://en.wikipedia.org/wiki/ISO_8601

Parameters
timeString- A std::string containing the ISO8601 time in the format YYYY-MM-DDTHH:MM:SS.SSSZ
Returns
returns a double variable containing the epoch time (seconds from 1970)
std::string glass3::util::Date::date18 ( )

Calculate the 20 character date string.

Calculate the 20 character date string in the form 1988Jan23 1234 12.21 from the Gregorian seconds.

Returns
Returns a std::string containing the date string
std::string glass3::util::Date::date20 ( )

Calculate the 18 character date string.

Calculate the 18 character date string in the form 88Jan23 1234 12.21 from the Gregorian seconds.

Returns
Returns a std::string containing the date string
std::string glass3::util::Date::dateTime ( )

Calculate the DateTime date string.

Calculate the date time string in the form 'yyyymmddhhmmss.sss' from the Gregorian seconds assuming base time is already UTC.

Returns
Returns a std::string containing the datetime string
unsigned int glass3::util::Date::day ( )

Get the gregorian day.

Get the current gregorian day

Returns
Returns an unsigned integer containing the gregorian day.
double glass3::util::Date::decodeDateTime ( std::string  datetime)

Decode the datetime format date string into Gregorian seconds.

Decode the datetime format date string 'yyyymmddhhmmss.sss' into Gregorian seconds.

Returns
Returns a double containing the Gregorian seconds
double glass3::util::Date::decodeISO8601Time ( std::string  iso8601)

Decode the ISO8601 date string into Gregorian seconds.

Decode the ISO8601 format date string 'YYYY-MM-DDTHH:MM:SS.SSSZ' into Gregorian seconds.

Returns
Returns a double containing the Gregorian seconds
std::string glass3::util::Date::encodeDateTime ( double  t)
static

Calculate (encode) the date time date string.

Calculate the date time string in the form 'yyyymmddhhmmss.sss' from the Gregorian seconds assuming base time is already UTC.

Returns
Returns a std::string containing the date string
std::string glass3::util::Date::encodeISO8601Time ( double  t)
static

Calculate (encode) the ISO8610 date string.

Calculate the ISO8601 date string in the form 'YYYY-MM-DDTHH:MM:SS.SSSZ' from the Gregorian seconds assuming base time is already UTC.

Returns
Returns a std::string containing the date string
unsigned int glass3::util::Date::hour ( )

Get the gregorian hour.

Get the current gregorian hour

Returns
Returns an unsigned integer containing the gregorian hour.
bool glass3::util::Date::initialize ( double  time)

CDate initialize function.

Initialize function for the CDate class, initializes the class from a provided time in Gregorian seconds.

Parameters
time- A double value containing the time in Gregorian seconds
Returns
returns true if successful, false otherwise
bool glass3::util::Date::initialize ( unsigned int  year,
unsigned int  month,
unsigned int  day,
unsigned int  hour,
unsigned int  minutes,
double  seconds 
)

CDate alternate initialize function.

Initialize function for the CDate class, initializes the class from a provided gregorian date/time.

Parameters
year- An unsigned integer value containing the year
month- An unsigned integer value containing the month
day- An unsigned integer value containing the day
hour- An unsigned integer value containing the hour
minutes- An unsigned integer value containing the minutes
seconds- A double value containing the seconds
Returns
returns true if successful, false otherwise
bool glass3::util::Date::initialize ( std::string  time)

CDate alternate initialize function.

Initialize function for the CDate class, initializes the class from a provided time string.

Parameters
time- A string value containing the time
Returns
returns true if successful, false otherwise
std::string glass3::util::Date::ISO8601 ( )

Calculate the ISO8601 date string.

Calculate the ISO8601 date string in the form 'YYYY-MM-DDTHH:MM:SS.SSSZ' from the Gregorian seconds assuming base time is already UTC.

Returns
Returns a std::string containing the date string
unsigned int glass3::util::Date::minute ( )

Get the gregorian minute.

Get the current gregorian minute

Returns
Returns an unsigned integer containing the gregorian minute.
unsigned int glass3::util::Date::month ( )

Get the gregorian month.

Get the current gregorian month

Returns
Returns an unsigned integer containing the gregorian month.
double glass3::util::Date::now ( )
static

CDate current time function.

gets the current time in Gregorian seconds

Returns
Returns a double containing the Gregorian seconds.
double glass3::util::Date::seconds ( )

Get the gregorian seconds.

Get the current gregorian seconds

Returns
Returns a double containing the gregorian seconds.
double glass3::util::Date::time ( )

Get the Gregorian seconds.

Get the total Gregorian seconds

Returns
Returns a double containing the Gregorian seconds.
unsigned int glass3::util::Date::year ( )

Get the gregorian year.

Get the current gregorian year

Returns
Returns an unsigned integer containing the gregorian year.

Member Data Documentation

double glass3::util::Date::m_dSeconds
protected

A double variable containing the gregorian seconds.

double glass3::util::Date::m_dTime
protected

A double variable containing the Gregorian seconds.

unsigned int glass3::util::Date::m_nDay
protected

An unsigned integer variable containing the gregorian day.

unsigned int glass3::util::Date::m_nHour
protected

An unsigned integer variable containing the gregorian hour.

unsigned int glass3::util::Date::m_nMinute
protected

An unsigned integer variable containing the gregorian minute.

unsigned int glass3::util::Date::m_nMonth
protected

An unsigned integer variable containing the gregorian month.

unsigned int glass3::util::Date::m_nYear
protected

An unsigned integer variable containing the gregorian year.


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