DTime+, A collection of Date and Time Classes for C++

Version 3.32

Copyright (c) 1995 - 2023 PJ Naughter

 

DTime+ is a collection of classes & functions designed to ease the C++ programmers’ burden when handling date and time values. If like me, having taken a look at the built in MFC classes CTime and CTimeSpan or the OLE based COleDateTime and COleDateTimeSpan classes in Visual Studio, you decided they did not meet your requirements, and you decided to write your own super-duper date and time classes, but deadlines were looming, then look no further. The original basis of the algorithms for conversion from the Julian and Gregorian calendar to the underlying storage was adopted from an article by Peter J.G. Meyer for the March 1993 issue of Dr Dobbs Journal. You can find the article online at http://www.drdobbs.com/cpp/julian-and-gregorian-calendars/184408959. As of v3.21, the code for the Julian and Gregorian calendar has been reworked to now be based on Howard Hinnant's algorithms at http://howardhinnant.github.io/date_algorithms.html. The algorithm used to determine the date of Easter Sunday is taken from the book ‘Astronomical Algorithms’ by Jean Meeus. The algorithms for the Moslem (Islamic) and Hebrew calendar are provided by the book "Calendrical Calculations, The Millenium Edition" by Edward M. Reingold and Nachum Dershowitz. Calendrical Calculations has always been a favourite topic of the author and was in fact some of the first code which I published on the web back in the mid 90's. Originally the code was shareware but I've now decided to make it freeware in the hope that more people will find it useful in their day to day projects. As of v3.20, the classes are fully supported on non Windows platforms. All the code has been carefully reviewed and reworked to support this. The code has been tested on VC 2017/2019 & 2022 on Windows and on Ubuntu using gcc, cmake and Code::Blocks.

 

 

 

Sections in this Document

Copyright

Features

History

How to Use

CDate Index

CLTimeSpan Index

CLLTimeSpan Index

CLTimeOfDay Index

CLLTimeOfDay Index

CLDate Index

CLLDate Index

Structures used by the classes

UI Support

Contacting the Author

 

 

 

Copyright

 

 

 

Features

 

 

 

History

v3.32 (30 October 2023)

v3.31 (3 June 2023)

v3.30 (22 May 2022)

v3.29 (29 December 2021)

v3.28 (21 May 2020)

v3.27 (16 May 2020)

v3.26 (17 December 2019)

v3.25 (13 October 2019)

v3.24 (8 June 2019)

v3.23 (13 November 2018)

v3.22 (2 January 2018)

v3.21 (20 December 2016)

v3.20 (6 December 2016)

v3.10 (26 October 2014)

v3.09 (13 April 2007)

v3.08 (2 July 2006)

v3.07 (30 May 2006)

v3.06 (29 May 2006)

v3.05 (27 May 2006)

v3.04 (25 May 2006)

v3.03 (22 May 2006)

v3.02 (20 May 2006)

v3.01 (1 May 2006)

v3.0 (22 April 2006)

11 April 2000

v2.22 (14 May 1999)

v2.21 (17 July 1998)

v2.2

v2.1

v2.0

v1.11

v1.1

v1.0

 

 

 

How to use

As DTime+ is provided as a C++ template class library, you simple need to #include the relevant header files (e.g. DTime+.h) in your project. You can also reference individual DTime+ headers also if you want. For example if you want to use the UI support for DTime+, you can include DTime+UI.h. On Windows you will need at least Visual C++ 2017 and compiled using /std:c++17, while on non-Windows platforms any recent copy of gcc should do.

 

 

 

CDate Index

Construction

CDate

Setting

Set

Static Constructors

CurrentSystemDate

CurrentLocalDate

JDEpoch

MJDEpoch

Epoch1900

Epoch1950

EpochCTime

Epoch2000

GregorianEpoch

Static Operations

IsLeap

DaysInYear

DaysInMonth

DaysSinceFirstOfYear

DaysSinceEndPreviousYear

GetFullStringDayOfWeek

GetAbrStringDayOfWeek

GetFullStringMonth

GetAbrStringMonth

Operations

DaysSinceFirstOfYear

DaysSinceEndPreviousYear

GetDate

GetDay

GetMonth

GetYear

GetCEBCEYear

Get2DigitYear

GDN

JD

IsLeap

DaysInYear

DaysInMonth

AddYear

AddMonth

AddWeek

GetDayOfWeek

GetFullStringDayOfWeek

GetAbrStringDayOfWeek

GetFullStringMonth

GetAbrStringMonth

GetAsSystemTime

GetAsFileTime

GetAsTM

GetWeekOfYear

GetWeekOfMonth

IsValid

Collate

Construction based on this instance

FirstThisMonth

LastThisMonth

FirstThisYear

LastThisYear

Overloaded Arithmetic Operators

operator=

operator+,-

operator+=, -=

operator++

operator--

operator==, <, etc.

Display

GetWindowsFormatString

Format

Serialization

Serialize

operator<<

operator>>

 

 

CDate::CDate

CDate();

CDate(int32_t Year, uint16_t month, uint16_t Day, bool bDoAssert = true);

CDate(const SYSTEMTIME& SystemTime, bool bDoAssert = true);

CDate(const FILETIME& FileTime, bool bDoAssert = true);

CDate(int32_t Year, uint16_t month, uint16_t WeekOfMonth, DayOfWeek dow, bool bDoAssert = true);

CDate(int32_t Days, DateEpoch e, bool bDoAssert = true);

CDate(const CDate& d);

CDate(const CTime& ctime, bool bDoAssert = true);

CDate(const COleDateTime& oleTime, bool bDoAssert = true);

CDate(const String& sDate, const String& sFormat, bool bDoAssert = true);

Parameters

Year, Month, Day Indicates a year, month and day.

SystemTime A Win32 SDK SYSTEMTIME struct.

FileTime A Win32 SDK FILETIME struct.

d Indicates a CDate object that already exists.

ctime Indicates a CTime object that already exists.

WeekOfMonth The week of the month (1 - 5).

DayOfWeek The day of the week e.g. Sunday.

oleTime An OLE Date.

sDate A string representation of the date to construct

sFormat The format that the string date uses

bDoAsserts If set, the constructors will assert in debug mode if any of the parameters are invalid

Remarks

sFormat                    sDate                       Result
‘dmy2/’                    ‘20/03/96’               20th March 1996
‘mdy4-’                     ‘03-28-1996’            28th March 1996

This feature allows for the creation of CDate's from a string as entered in a masked edit field or from a parsed report.

 

CDate::Set

CDate& Set();

CDate& Set(int32_t Year, uint16_t month, uint16_t Day, bool bDoAssert = true);

CDate& Set(const SYSTEMTIME& SystemTime, bool bDoAssert = true);

CDate& Set(const FILETIME& FileTime, bool bDoAssert = true);

CDate& Set(int32_t Year, uint16_t month, uint16_t WeekOfMonth, DayOfWeek dow, bool bDoAssert = true);

CDate& Set(int32_t Days, CDate::DateEpoch e, bool bDoAssert = true);

CDate& Set(const CTime& ctime, bool bDoAssert = true);

CDate& Set(const COleDateTime& oleTime);

CDate& Set(const String& sDate, const String& sFormat, bool bDoAssert = true);

Parameters

See CDate Constructors

Remarks

 

static CDate::CurrentSystemDate(bool bDoAssert = true);

Returns a CDate which represents the current UTC date as taken from the system clock.

 

static CDate::CurrentLocalDate(bool bDoAssert = true);

Returns a CDate which represents the current local date as taken from the system clock.

 

static CDate CDate::JDEpoch();

Returns a CDate which represents Julian Day Epoch i.e. 1st January -4712 (when specified in the Julian calendar)

 

static CDate CDate::MJDEpoch();

Returns a CDate which represents 1st January -4712 + 2400000 Days (which corresponds to 17 November 1858 in the Gregorian calendar)

 

static CDate CDate::Epoch1900();

Returns a CDate which represents 1st January 1900

 

static CDate CDate::Epoch1950();

Returns a CDate which represents 1st January 1950

 

static CDate CDate::EpochCTime();

Returns a CDate which represents a CTime of 0 seconds (i.e. 1st January 1970)

 

static CDate CDate::Epoch2000();

Returns a CDate which represents 1st January 2000

 

static CDate CDate::GregorianEpoch();

Returns a CDate which represents when the change from the Julian to Gregorian calendar occurred.

 

static bool CDate::IsLeap(int32_t Year);

returns true if the year is leap otherwise false.

Remarks

The routine correctly allows for the exception whereby dates in the Gregorian calendar are leap (or bissextile) if divisible by 4 with the following exception: the centurial years that are not divisible by 400, such as 1700, 1800, 1900, and 2100, are not leap years. The other century years, which are divisible by 400, are leap years, for instance 1600, 2000 and 2400. If we have instantiated for the Julian Calendars, then the simpler 4 year leap year rule is applied. If we have instantiated the CDate for the Moslem or Hebrew calendars, then their specific leap year / leap month rules will be applied.

 

static uint16_t CDate::DaysInYear(int32_t Year);

Returns the number of days in a year i.e. 366 if the year is leap otherwise 365, assuming we have instantiated the CDate class using the Gregorian or Julian Calendars. If instantiated for the Moslem or Hebrew calendars, then their specific leap year / leap month rules will be applied. In the Moslem calendar, a year can contain 354 or 355 days. In the Hebrew calendar, a year can contain 353, 354, 355, 383, 384 or 385 days.

 

static uint16_t CDate::DaysInMonth(int32_t Year, uint16_t month);

Returns the number of days in a month e.g. 31 for January, 28 for a common February, 29 for a leap February etc, assuming we have instantiated the CDate class using the Gregorian or Julian Calendars. If instantiated for the Moslem or Hebrew calendars, then their specific leap year / leap month rules will be applied.

 

static uint16_t CDate::DaysSinceFirstOfYear(int32_t Year, uint16_t month, uint16_t Day);

Returns the number of days since 1st of January. If the CDate class has been instantiated using the Moslem calendar, then the first of the year will correspond to the 1st day of the Moslem month Muharram. If the CDate class has been instantiated using the Hebrew calendar, then it returns the number of days since 1st day of Tishri. Note this function does not return the number of days since 1st of Nisan which is the 1st month in the Hebrew calendar because Hebrew New Year is 1st of Tishri which is the 7th month.

 

static uint16_t CDate::DaysSinceEndPreviousYear(int32_t Year, uint16_t month, uint16_t Day);

Returns the number of days since 0th of January (previous 31st December). If the CDate class has been instantiated using the Moslem calendar, then the end of the previous year will correspond to the 29th or 30th of the Moslem month Dhu al-Hijja. If the CDate class has been instantiated using the Hebrew calendar, then it returns the number of days since 0th of Tishri (previous 29th of Elul). Note this function does not return the number of days since the last day of Adar I or Adar II (if it is a leap year) because Hebrew New Year is 1st of Tishri which is the 7th month.

 

static String CDate::GetFullStringDayOfWeek();

Returns a representation of the day of week parameter as a String, returning for example ‘Sunday’, ‘Monday’ etc assuming you have constructed the CDate instance using the Julian or Gregorian calendar.

Remarks

See Also

CDate::GetAbrStringDayOfWeek

 

static String CDate::GetAbrStringDayOfWeek();

Returns an abbreviated representation for the day of week parameter as a String, returning for example ‘Sun’, ‘Mon’ etc assuming you have constructed the CDate instance using the Julian or Gregorian calendar.

Remarks

See Also

CDate::GetFullStringDayOfWeek

 

static String CDate::GetFullStringMonth();

Returns a String representation for the month parameter, returning for example ‘January’, ‘February’ etc assuming you have constructed the CDate instance using the Julian or Gregorian calendar.

See Also

CDate::GetAbrStringMonth

 

static String CDate::GetAbrStringMonth();

Returns a String representation for the month parameter, returning for example ‘Jan’, ‘Feb’ etc assuming you have constructed the CDate instance using the Julian or Gregorian calendar.

See Also

CDate::GetFullStringMonth

 

uint16_t CDate::DaysSinceFirstOfYear() const;

Returns the number of days since 1st of January for this instance. If the CDate class has been instantiated using the Moslem calendar, then the first of the year will correspond to the 1st day of the Moslem month Muharram.

 

uint16_t CDate::DaysSinceEndPreviousYear() const;

Returns the number of days since 0th of January (previous 31st December) for this instance. If the CDate class has been instantiated using the Moslem calendar, then the end of the previous year will correspond to 29th or 30th of the Moslem month Dhu al-Hijja.

 

CDate::DateS CDate::GetDate() const;

Returns a DateS structure for this instance.

 

uint16_t CDate::GetDay() const;

Returns the Day of the month for this instance (1 - 31).

 

uint16_t CDate::GetMonth() const;

Returns the Month enum for this instance (January(1) - December (12)).

 

int32_t CDate::GetYear() const;

Returns the Year for this instance.

 

int32_t CDate::GetCEBCEYear(bool& IsCE) const;

Returns the Current Epoch / Before Current Epoch year for this instance.

e.g.

bool bIsCE;

CDate<CGregorianCalendar> x(1990, January, 32);

int32_t y = x.GetCEBCEYear(bIsCE);        //y will be 1990, bIsCE will be true

x.Set(-1990, January, 32);

y = x.GetCEBCEYear(bIsCE);                   //y will be 1989, bIsCE will be false

 

int32_t CDate::Get2DigitYear() const;

Returns the last 2 digits of the year.

e.g.

CDate<CGregorianCalendar> x(1995, January, 15);

int32_t y = x.Get2DigitYear();

assert(y == 95);

 

int32_t CDate::GDN() const;

Returns the number of days for this instance since the Gregorian Epoch.

 

int32_t CDate::JD() const;

Returns the Julian Day or number of days for this instance since 1st January -4712.

 

bool CDate::IsLeap() const;

Returns true if the year for this instance is leap otherwise false.

 

uint16_t CDate::DaysInYear() const;

Returns the number of days for this instance’s year.

 

uint16_t CDate::DaysInMonth() const;

Returns the number of days for this instance’s month.

 

void CDate::AddYear(int Years = 1);

Adds a number of years to this instance.

 

void CDate::AddMonth(int Months = 1);

Adds a number of months to this instance.

Remarks

 

void CDate::AddWeek(int Weeks = 1);

Adds a number of weeks i.e. 7 days to this instance.

 

uint16_t CDate::GetDayOfWeek() const;

Returns the day of week for this instance. (1 for Sunday, 2 for Monday, and so forth).

Remarks

 

String CDate::GetFullStringDayOfWeek() const;

Returns the day of week for this instance as a String. e.g. 'Sunday', 'Monday' etc  assuming you have constructed a Julian or Gregorian CDate instance.

See Also

CDate::GetAbrStringDayOfWeek

 

String CDate::GetAbrStringDayOfWeek() const;

Returns an abbreviated String version for the day of week for this instance. e.g. ‘Sun’, ‘Mon’ etc assuming you have constructed a Julian or Gregorian CDate instance.

See Also

CDate::GetFullStringDayOfWeek

 

String CDate::GetFullStringMonth() const;

Returns the full String version for the month for this instance. e.g. ‘January’, ‘February’ etc assuming you have constructed a Julian or Gregorian CDate instance.

See Also

CDate::GetAbrStringMonth

 

String CDate::GetAbrStringMonth() const;

Returns an abbreviated String version for the month for this instance. e.g. ‘Jan’, ‘Feb’ etc assuming you have constructed a Julian or Gregorian CDate instance.

See Also

CDate::GetFullStringMonth

 

bool CDate::GetAsSystemTime(SYSTEMTIME& SystemTime) const;

Returns a Win32 SDK SYSTEMTIME struct version of this instance if this method succeeds by returning true.

Remarks

 

bool CDate::GetAsFileTime(FILETIME& FileTime) const;

Returns a Win32 SDK FILETIME struct version of this instance if this method succeeds by returning true.

Remarks

 

bool CDate::GetAsTM(tm& time) const;

Returns a ‘C’ runtime tm struct version of this instance if this method succeeds by returning true.

 

uint16_t CDate::GetWeekOfYear() const;

Returns the week of the year for this instance. As an example of how this is determined:

Suppose the 1st of January occurred on a Thursday and the day of week considered the beginning of the week is Monday as specified by the locale value 'Locale'. The following results would then be obtained:

Date                        GetWeekOfYear() return value

Thursday 1st            0

Friday 2nd                0

Saturday 3rd            0

Sunday 4th              0

Monday 5th             1

Tuesday 6th            1

.

.

Monday 12th           2

.

.

.

 

uint16_t CDate::GetWeekOfMonth() const;

Returns the week of the month for this instance. As an example of how this is determined:

Suppose the 1st of the month occurred on a Thursday and the day of week considered the beginning of the week is Monday as specified by the locale value 'Locale', The following results would then be obtained:

Date                        GetWeekOfMonth() return value

Thursday 1st            0

Friday 2nd                0

Saturday 3rd            0

Sunday 4th              0

Monday 5th             1

Tuesday 6th            1

.

.

Monday 12th           2

.

.

.

 

bool CDate::IsValid() const;

Returns true if this instance is valid otherwise false.

e.g. CDate<CGregorianCalendar> Inval(1990, January, 33, false); //an invalid day of month

assert(IsValid(Inval) == false);

 

int32_t CDate::Collate() const;

Returns a int32_t which can be used in a date collation purposes i.e. the year value is stored as units of 10000, the month value is stored as units of 100 and the day value as units of 1.

ee.g. CDate<CGregorianCalendar> x(1978, March, 3);

assert(x.Collate() = 19780403L);/p>  

CDate CDate::FirstThisMonth();

Returns a CDate for the first of the month for this instance

e.g. CDate<CGregorianCalendar> x(1990, March, 4);

CDate<CGregorianCalendar> f(x.FirstThisMonth());

assert(f = CDate<CGregorianCalendar>(1990, March, 1);

See Also

CDate::LastThisMonth

 

CDate CDate::LastThisMonth();

Returns a CDate for the last of the month for this instance

e.g. CDate<CGregorianCalendar> x(1990, March, 4);

CDate<CGregorianCalendar> f(x.LastThisMonth());

assert(f = CDate<CGregorianCalendar>(1990, CDate::March, 31);

See Also

CDate::FirstThisMonth

 

CDate CDate::FirstThisYear();

Returns a CDate for the 1st January for this instance

e.g. CDate<CGregorianCalendar> x(1990, March, 4);

CDate<CGregorianCalendar> f(x.FirstThisYear());

assert(f = CDate<CGregorianCalendar>(1990, January, 1);

See Also

CDate::LastThisYear

 

CDate CDate::LastThisYear();

Returns a CDate for the 31st December for this instance

e.g. CDate<CGregorianCalendar> x(1990, March, 4);

CDate<CGregorianCalendar> f(x.LastThisYear());

assert(f = CDate<CGregorianCalendar>(1990, December, 31);

See Also

CDate::FirstThisYear

 

CDate& CDate::operator=(const CDate& d);

Copies a CDate into this CDate and returns a reference to this instance

 

CDate CDate::operator+(int32_t Days) const;

CDate CDate::operator-(int32_t Days) const;

Standard arithmetic operators to add and subtracts a number of days.

e.g. CDate<CGregorianCalendar> Tomorrow(CDate<CGregorianCalendar>::CurrentLocalDate()) + 1;

int32_t OneMonth = CDate<CGregorianCalendar>(1990, March, 4) - CDate<CGregorianCalendar>(1990, February, 4);

CDate<CGregorianCalendar> Yesterday(CDate<CGregorianCalendar>::GetLocalDate()) - 1;

 

CDate& CDate::operator+=(int32_t Days);

CDate& CDate::operator-=(int32_t Days);

Standard arithmetic increment and decrement operators

e.g. CDate<CGregorianCalendar> x(1990, January, 1);

x += 7;

assert(x == CDate<CGregorianCalendar>(1990, January, 8));

x -= 7;

assert(x == CDate<CGregorianCalendar>(1990, January, 1));

 

CDate& CDate::operator++();

Standard arithmetic increment operator. Adds one day to this instance

 

CDate& CDate::operator--();

Standard arithmetic decrement operator. Subtracts one day from this instance.

 

bool CDate::operator==(const CDate& d) const;

bool CDate::operator>(const CDate& d) const;

bool CDate::operator>=(const CDate& d) const;

bool CDate operator<(const CDate& d) const;

bool CDate operator<=(const CDate& d) const;

bool CDate operator!=(const CDate& d) const;

Standard arithmetic equality operators.

 

String CDate::GetWindowsFormatString(LPCWSTR lpLocaleName = LOCALE_NAME_USER_DEFAULT)

Returns a CDate::Format string appropriate for the specified windows locale as specified by 'lpLocaleName'

See Also

CDate::Format

 

String CDate::Format(const String& sFormat) const;

Generates a formatted string that corresponds to this CDate object.

The sFormat string supports the following replaceable parameters:

Remarks

See Also

CDate::GetWindowsFormatString

 

void CDate::Serialize(CArchive& ar);

Standard MFC override to allow streaming of this CDate to and from an archive. The space taken is 6 bytes (4 data bytes + 2 schema bytes).

Remarks

As of v3 of DTime+, the serialization is not backward compatible with earlier versions.

 

friend CArchive& operator<<(CArchive& ar, CDate& Date);

Simply calls the Serialize method of ‘Date’, asserting that the archive ‘ar’ is storing.

 

friend CArchive& operator>>(CArchive& ar, CDate& Date);

Simply calls the Serialize method of ‘Date’, asserting that the archive ‘ar’ is loading.

 

 

 

CLTimeSpan Index

Construction

CLTimeSpan

Setting

Set

Static Constructors

OneDay

OneHour

OneMinute

OneSecond

Operations

GetTotalDays

GetHours

GetMinutes

GetSeconds

IsValid

Negate

IsPositiveSpan

SecondsAsDouble

Overloaded Arithmetic Operators

operator=

operator+,-

operator+=.-=

operator*, /

operator*=, /=

Overloaded Equality Operators

operator==, > etc.

Display

Format

Serialization

Serialize

operator<<

operator>>

 

CLTimeSpan Constructors

CLTimeSpan();

CLTimeSpan(int32_t Day, uint16_t Hour, uint16_t Minute, uint16_t Second);

CLTimeSpan(const CLTimeSpan& lts);

CLTimeSpan(const CTimeSpan& ts);

CLTimeSpan(const CLTimeOfDay& tod);

CLTimeSpan(const COleDateTimeSpan& oleTimeSpan);

CLTimeSpan(const int64_t& Seconds);

Parameters

Day, Hour, Minute, Second Indicates a count of day, hour, minute and second values.

lts Indicates a CLTimeSpan object that already exists.

ts Indicates a CTimeSpan object that already exists.

tod Indicates a CLTimeOfDay object that already exists.

Seconds Indicates a count of seconds as a 64 bit integer.

oleTime An OLE time span.

Remarks

 

CLTimeSpan Set functions

CLTimeSpan& Set();

CLTimeSpan& Set(int32_t Day, uint16_t Hour, uint16_t Minute, uint16_t Second);

CLTimeSpan& Set(const CTimeSpan& ts);

CLTimeSpan& Set(const CLTimeOfDay& tod);

CLTimeSpan& Set(const COleDateTimeSpan& oleTimeSpan);

CLTimeSpan& Set(const int64_t& Seconds);

Parameters

See CLTimeSpan Constructors

Remarks

 

static CLTimeSpan CLTimeSpan::OneDay();

Returns a CLTimeSpan which represents one day.

 

static CLTimeSpan CLTimeSpan::OneHour();

Returns a CLTimeSpan that represents one hour.

 

static CLTimeSpan CLTimeSpan::OneMinute();

Returns a CLTimeSpan that represents one minute.

 

static CLTimeSpan CLTimeSpan::OneSecond();

Returns a CLTimeSpan that represents one second.

 

int32_t CLTimeSpan::GetTotalDays() const;

Returns the total number of days this CLTimeSpan contains.

e.g. CLTimeSpan x(10, 12 , 13, 14)

assert(x.GetTotalDays() == 10);

 

uint16_t CLTimeSpan::GetHours() const;

Returns the number of hours this CLTimeSpan contains.

e.g. CLTimeSpan x(10, 12 , 13, 14)

assert(x.GetHours() == 12);

 

uint16_t CLTimeSpan::GetMinutes() const;

Returns the number of minutes this CLTimeSpan contains.

e.g. CLTimeSpan x(10, 12 , 13, 14)

assert(x.GetMinutes() == 13);

 

uint16_t CLTimeSpan::GetSeconds() const;

Returns the number of seconds this CLTimeSpan contains.

e.g. CLTimeSpan x(10, 12 , 13, 14)

assert(x.GetSeconds() == 14);

 

bool CLTimeSpan::IsValid() const;

Returns true if this instance is valid otherwise false.

e.g. CLTimeSpan Inval;

assert(IsValid(Inval) == false);

 

CLTimeSpan& CLTimeSpan::Negate();

Negates this CLTimeSpan instance and returns a reference to it.

e.g. CLTimeSpan x(10, 12 , 13, 14)

x.Negate();

assert(x == CLTimeSpan(-10, 12, 13, 14);

 

bool CLTimeSpan::IsPositiveSpan() const;

Returns true if this CLTimeSpan represents a positive time span (value >= 0 seconds) else false is returned.

e.g. CLTimeSpan x(-10, 12 , 13, 14)

assert(!x.IsPositiveSpan());

 

double CLTimeSpan::SecondsAsDouble() const;

Returns the underlying number of seconds this CLTimeSpan contains as a double.

 

CLTimeSpan& CLTimeSpan::operator=(const CLTimeSpan& TimeSpan)

Copies a CLTimeSpan into this CLTimeSpan and returns a reference to this instance

 

CLTimeSpan CLTimeSpan::operator+(const CLTimeSpan& TimeSpan) const;

CLTimeSpan CLTimeSpan::operator-(const CLTimeSpan& TimeSpan) const;

Standard arithmetic operators to add and subtracts CLTimeSpan’s.

 

CLTimeSpan& CLTimeSpan::operator+=(const CLTimeSpan& TimeSpan);

CLTimeSpan& CLTimeSpan::operator-=(const CLTimeSpan& TimeSpan);

Standard arithmetic auto increment and decrement operators.

 

CLTimeSpan CLTimeSpan::operator*(uint16_t Multiplier) const;

CLTimeSpan operator*(uint16_t Multiplier, const CLTimeSpan& TimeSpan);

CLTimeSpan CLTimeSpan::operator/(uint16_t divisor) const;

Standard arithmetic operators to multiply and divide CLTimeSpan’s.

 

CLTimeSpan& CLTimeSpan::operator*=(uint16_t Multiplier);

CLTimeSpan& CLTimeSpan::operator/=(uint16_t Divisor);

Standard arithmetic auto multiply and divide operators.

 

bool CLTimeSpan::operator==(const CLTimeSpan& TimeSpan) const;

bool CLTimeSpan::operator>(const CLTimeSpan& TimeSpan) const;

bool CLTimeSpan::operator>=(const CLTimeSpan& TimeSpan) const;

bool CLTimeSpan::operator<(const CLTimeSpan& TimeSpan) const;

bool CLTimeSpan::operator<=(const CLTimeSpan& TimeSpan) const;

bool CLTimeSpan::operator!=(const CLTimeSpan& TimeSpan) const;

Standard arithmetic equality operators.

 

String CLTimeSpan::GetWindowsFormatString(LPCWSTR lpLocaleName = LOCALE_NAME_USER_DEFAULT)

Returns a CLTimeSpan::Format string appropriate appropriate for the specified windows locale as specified by 'lpLocaleName'.

See Also

CLTimeSpan::Format

 

String CLTimeSpan::Format(const String& sFormat) const;

Generates a formatted string that corresponds to this CLTimeSpan object.

The sFormat string supports the following replaceable parameters:

Remarks

See Also

CLTimeSpan::GetWindowsFormatString

 

void CLTimeSpan::Serialize(CArchive& ar);

Standard MFC override to allow streaming of this CLTimeSpan to and from an archive. The space taken is 10 bytes (8 data bytes + 2 schema bytes).

Remarks

As of v3 of DTime+, the serialization is not backward compatible with earlier versions.

 

friend CArchive& operator<<(CArchive& ar, CLTimeSpan& TimeSpan);

Simply calls the Serialize method of ‘TimeSpan’, asserting that the archive ‘ar’ is storing.

 

friend CArchive& operator>>(CArchive& ar, CLTimeSpan& TimeSpan);

Simply calls the Serialize method of ‘TimeSpan’, asserting that the archive ‘ar’ is loading.

 

 

 

CLLTimeSpan Index

Construction

CLLTimeSpan

Setting

Set

Static Constructors

OneDay

OneHour

OneMinute

OneSecond

Operations

GetTotalDays

GetHours

GetMinutes

GetSeconds

IsValid

Negate

IsPositiveSpan

Overloaded Arithmetic Operators

operator=

operator+,-

operator+=.-=

operator*, /

operator*=, /=

Overloaded Equality Operators

operator==, > etc.

Display

Format

Serialization

Serialize

operator<<

operator>>

 

CLLTimeSpan Constructors

CLLTimeSpan();

CLLTimeSpan(int32_t Day, uint16_t Hour, uint16_t Minute, double Second);

CLLTimeSpan(const CLLTimeSpan& lts);

CLLTimeSpan(const CTimeSpan& ts);

CLLTimeSpan(const COleDateTimeSpan& oleTimeSpan);

CLLTimeSpan(const double& Seconds);

Parameters

Day, Hour, Minute, Second Indicates a count of day, hour, minute and second values.

lts Indicates a CLTimeSpan object that already exists.

ts Indicates a CTimeSpan object that already exists.

Seconds Indicates a count of seconds as a 64 bit integer.

oleTime An OLE time span.

Remarks

 

CLLTimeSpan Set functions

CLLTimeSpan& Set();

CLLTimeSpan& Set(int32_t Day, uint16_t Hour, uint16_t Minute, double Second);

CLLTimeSpan& Set(const CTimeSpan& ts);

CLLTimeSpan& Set(const COleDateTimeSpan& oleTimeSpan);

CLLTimeSpan& Set(const int64_t& Seconds);

Parameters

See CLLTimeSpan Constructors

Remarks

 

static CLLTimeSpan CLTimeSpan::OneDay();

Returns a CLTimeSpan which represents one day.

 

static CLLTimeSpan CLTimeSpan::OneHour();

Returns a CLTimeSpan that represents one hour.

 

static CLLTimeSpan CLTimeSpan::OneMinute();

Returns a CLTimeSpan that represents one minute.

 

static CLLTimeSpan CLTimeSpan::OneSecond();

Returns a CLTimeSpan that represents one second.

 

int32_t CLLTimeSpan::GetTotalDays() const;

Returns the total number of days this CLTimeSpan contains.

e.g. CLTimeSpan x(10, 12 , 13, 14)

assert(x.GetTotalDays() == 10);

 

uint16_t CLLTimeSpan::GetHours() const;

Returns the number of hours this CLTimeSpan contains.

e.g. CLTimeSpan x(10, 12 , 13, 14)

assert(x.GetHours() == 12);

 

uint16_t CLLTimeSpan::GetMinutes() const;

Returns the number of minutes this CLTimeSpan contains.

e.g. CLTimeSpan x(10, 12 , 13, 14)

assert(x.GetMinutes() == 13);

 

double CLLTimeSpan::GetSeconds() const;

Returns the number of seconds this CLTimeSpan contains.

e.g. CLTimeSpan x(10, 12 , 13, 14)

assert(x.GetSeconds() == 14);

 

bool CLLTimeSpan::IsValid() const;

Returns true if this instance is valid otherwise false.

e.g. CLTimeSpan Inval;

assert(IsValid(Inval) == false);

 

CLTimeSpan& CLLTimeSpan::Negate();

Negates this CLTimeSpan instance and returns a reference to it.

e.g. CLTimeSpan x(10, 12 , 13, 14)

x.Negate();

assert(x == CLTimeSpan(-10, 12, 13, 14);

 

bool CLLTimeSpan::IsPositiveSpan() const;

Returns true if this CLTimeSpan represents a positive time span (value >= 0 seconds) else false is returned.

e.g. CLTimeSpan x(-10, 12 , 13, 14)

assert(!x.IsPositiveSpan());

 

CLLTimeSpan& CLLTimeSpan::operator=(const CLLTimeSpan& TimeSpan)

Copies a CLLTimeSpan into this CLLTimeSpan and returns a reference to this instance

 

CLLTimeSpan CLLTimeSpan::operator+(const CLLTimeSpan& TimeSpan) const;

CLLTimeSpan CLLTimeSpan::operator-(const CLLTimeSpan& TimeSpan) const;

Standard arithmetic operators to add and subtracts CLTimeSpan’s.

 

CLLTimeSpan& CLLTimeSpan::operator+=(const CLLTimeSpan& TimeSpan);

CLLTimeSpan& CLLTimeSpan::operator-=(const CLLTimeSpan& TimeSpan);

Standard arithmetic auto increment and decrement operators.

 

CLLTimeSpan CLLTimeSpan::operator*(double Multiplier) const;

CLLTimeSpan operator*(double Multiplier, const CLTimeSpan& TimeSpan);

CLLTimeSpan CLTimeSpan::operator/(double divisor) const;

Standard arithmetic operators to multiply and divide CLLTimeSpan’s.

 

CLLTimeSpan& CLLTimeSpan::operator*=(double Multiplier);

CLLTimeSpan& CLLTimeSpan::operator/=(double Divisor);

Standard arithmetic auto multiply and divide operators.

 

bool CLLTimeSpan::operator==(const CLLTimeSpan& TimeSpan) const;

bool CLLTimeSpan::operator>(const CLLTimeSpan& TimeSpan) const;

bool CLLTimeSpan::operator>=(const CLLTimeSpan& TimeSpan) const;

bool CLLTimeSpan::operator<(const CLLTimeSpan& TimeSpan) const;

bool CLLTimeSpan::operator<=(const CLLTimeSpan& TimeSpan) const;

bool CLLTimeSpan::operator!=(const CLLTimeSpan& TimeSpan) const;

Standard arithmetic equality operators.

 

String CLLTimeSpan::Format(const String& sFormat) const;

Generates a formatted string that corresponds to this CLLTimeSpan object.

The sFormat string supports the following replaceable parameters:

Remarks

 

void CLLTimeSpan::Serialize(CArchive& ar);

Standard MFC override to allow streaming of this CLTimeSpan to and from an archive. The space taken is 10 bytes (8 data bytes + 2 schema bytes).

Remarks

As of v3 of DTime+, the serialization is not backward compatible with earlier versions.

 

friend CArchive& operator<<(CArchive& ar, CLLTimeSpan& TimeSpan);

Simply calls the Serialize method of ‘TimeSpan’, asserting that the archive ‘ar’ is storing.

 

friend CArchive& operator>>(CArchive& ar, CLLTimeSpan& TimeSpan);

Simply calls the Serialize method of ‘TimeSpan’, asserting that the archive ‘ar’ is loading.

 

 

 

CLTimeOfDay Index

Constructors

CLTimeOfDay

Setting

Set

Static Constructors

CurrentSystemTime

CurrentLocalTime

Midnight

Midday

Static Operations

GetAMString

GetPMString

Operations

GetHours

GetMinutes

GetSeconds

GetTotalSeconds

GetAMPMHours

GetAMPMString

IsValid

Collate

GetAsSystemTime

GetAsTM

Overloaded Arithmetic Operators

operator=

operator+,-

operator+=.-=

Overloaded Equality Operators

operator==, > etc.

Display

GetWindowsFormatString

Format

Serialization

Serialize

operator<<

operator>>

 

CLTimeOfDay Constructors

CLTimeOfDay();

CLTimeOfDay(uint16_t Hour, uint16_t Minute, uint16_t Second, bool bDoAssert = true);

CLTimeOfDay(const SYSTEMTIME& st, bool bDoAssert = true);

CLTimeOfDay(const CLTimeOfDay& ltod);

CLTimeOfDay(uint32_t TotalSeconds, bool bDoAssert = true);

Parameters

Hour, Minute, Second Indicates a hour, minute and second values.

st A Win32 SYSTEMTIME structure.

ltod Indicates an existing CLTimeOfDay instance.

TotalSeconds Indicates a accumulated number of seconds.

bDoAsserts if set, the constructors will assert in debug mode if any of the parameters are invalid

Remarks

 

CLTimeOfDay Set functions

CLTimeOfDay& Set();

CLTimeOfDay& Set(uint16_t Hour, uint16_t Minute, uint16_t Second, bool bDoAssert = true);

CLTimeOfDay& Set(const SYSTEMTIME& st, bool bDoAssert = true);

CLTimeOfDay& Set(uint32_t TotalSeconds, bool bDoAssert = true);

Parameters

See CLTimeOfDay Constructors

Remarks

 

static CLTimeOfDay CLTimeOfDay::CurrentSystemTime();

Returns a CLTimeOfDay which represents the current UTC time of day as taken from the system clock.

 

static CLTimeOfDay CLTimeOfDay::CurrentLocalTime();

Returns a CLTimeOfDay which represents the current Local time of day as taken from the system clock.

 

static CLTimeOfDay CLTimeOfDay::Midnight();

Returns a CLTimeOfDay that represents midnight.

 

static CLTimeOfDay CLTimeOfDay::Midday();

Returns a CLTimeOfDay that represents midday.

 

static String CLTimeOfDay::GetAMString();

Returns the string to used for the 'AM' indicator for the current user locale.

 

static String CLTimeOfDay::GetPMString();

Returns the string to used for the 'PM' indicator for the current user locale.

 

uint16_t CLTimeOfDay::GetHours() const;

Returns the number of hours this CLTimeOfDay contains.

e.g. CLTimeOfDay<> x(12 , 13, 14, 15)

assert(x.GetHours() == 12);

 

uint16_t CLTimeOfDay::GetMinutes() const;

Returns the number of minutes this CLTimeOfDay contains.

e.g. CLTimeOfDay<> x(12 , 13, 14, 15)

assert(x.GetMinutes() == 13);

 

uint16_t CLTimeOfDay::GetSeconds() const;

Returns the number of seconds this CLTimeOfDay contains.

e.g. CLTimeOfDay<> x(12 , 13, 14, 15)

assert(x.GetSeconds() == 14);

 

uint32_t CLTimeOfDay::GetTotalSeconds() const;

Returns the total number of seconds this CLTimeOfDay contains.

e.g. CLTimeOfDay<> x(0 , 1, 14, 15)

assert(x.GetTotalSeconds() == 74);

 

uint16_t  CLTimeOfDay::GetAMPMHours() const;

Returns the 12 hour version of the hour this CLTimeOfDay represents.

e.g. CLTimeOfDay<> x(17 , 13, 14, 15)

assert(x.GetAMPMHour() == 5);

 

String CLTimeOfDay::GetAMPMString() const;

Returns the string to used for the 'AM'or 'PM' indicator for the current user locale for this instance's hour value.

 

bool CLTimeOfDay::IsValid() const;

Returns true if this instance is valid otherwise false.

e.g. CLTimeOfDay<> Inval;

assert(IsValid(Inval) == false);

 

uint32_t CLTimeOfDay::Collate() const;

Returns a uint32_t which can be used for time collation purposes i.e. the hours value is stored as units of 10000, the minutes value is stored as units of 100 and the seconds value as units of 1.

e.g. CLTimeOfDay<> x(13, 12, 11);

assert(x.Collate() = 131211L);

 

bool CLTimeOfDay::GetAsSystemTime(SYSTEMTIME& SystemTime) const;

Returns a SYSTEMTIME structure representing this CLTimeOfDay

Remarks

 

bool CLTimeOfDay::GetAsTM(tm& time) const;

Returns a ‘C’ runtime tm struct version of this instance.

 

CLTimeOfDay& CLTimeOfDay::operator=(const CLTimeOfDay& Tod);

Copies a CLTimeOfDay into this CLTimeOfDay instance and returns a reference to this instance.

 

CLTimeOfDay CLTimeOfDay::operator+(const CLTimeSpan& TimeSpan) const;

CLTimeOfDay CLTimeOfDay::operator-(const CLTimeSpan& TimeSpan) const;

Standard arithmetic operators to add and subtracts CLTimeOfDay’s.

 

CLTimeOfDay& CLTimeOfDay::operator+=(const CLTimeSpan& TimeSpan);

CLTimeSpan& CLTimeOfDay::operator-=(CLTimeSpan& TimeSpan);

Standard arithmetic auto increment and decrement operators.

 

bool CLTimeOfDay::operator==(const CLTimeOfDay& Tod) const;

bool CLTimeOfDay::operator>(const CLTimeOfDay& Tod) const;

bool CLTimeOfDay::operator>=(const CLTimeOfDay& Tod) const;

bool CLTimeOfDay::operator<(const CLTimeOfDay& Tod) const;

bool CLTimeOfDay::operator<=(const CLTimeOfDay& Tod) const;

bool CLTimeOfDay::operator!=(const CLTimeOfDay& Tod) const;

Standard arithmetic equality operators.

 

String CLTimeOfDay::GetWindowsFormatString(LPCWSTR lpLocaleName = LOCALE_NAME_USER_DEFAULT)

Returns a CLTimeOfDay::Format string appropriate for the specified windows locale as specified by 'lpLocaleName'

See Also

CLTimeOfDay::Format

 

String CLTimeOfDay::Format(const String& sFormat) const;

Generates a formatted string that corresponds to this CLTimeOfDay object.

The sFormat string supports the following replaceable parameters:

Remarks

See Also

CLTimeOfDay::GetWindowsFormatString

 

void CLTimeOfDay::Serialize(CArchive& ar);

Standard MFC override to allow streaming of this CLTimeOfDay to archive. The space taken is exactly 6 bytes (4 data bytes + 2 schema bytes).

Remarks

As of v3 of DTime+, the serialization is not backward compatible with earlier versions.

 

friend CArchive& operator<<(CArchive& ar, CLTimeSpan& Tod);

Simply calls the Serialize method of ‘Tod’, asserting that the archive ‘ar’ is storing.

 

friend CArchive& operator>>(CArchive& ar, CLTimeSpan& Tod);

Simply calls the Serialize method of ‘Tod’, asserting that the archive ‘ar’ is loading.

 

 

 

CLLTimeOfDay Index

Constructors

CLLTimeOfDay

Setting

Set

Static Constructors

CurrentSystemTime

CurrentLocalTime

Midnight

Midday

Static Operations

GetAMString

GetPMString

Operations

GetHours

GetMinutes

GetSeconds

GetAMPMHours

GetAMPMString

IsValid

GetAsSystemTime

Overloaded Arithmetic Operators

operator=

operator+,-

operator+=.-=

Overloaded Equality Operators

operator==, > etc.

Display

Format

Serialization

Serialize

operator<<

operator>>

 

CLLTimeOfDay Constructors

CLLTimeOfDay();

CLLTimeOfDay(uint16_t Hour, uint16_t Minute, double Second, bool bDoAssert = true);

CLLTimeOfDay(const SYSTEMTIME& st, bool bDoAssert = true);

CLLTimeOfDay(const CLLTimeOfDay& ltod);

CLLTimeOfDay(double TotalSeconds, bool bDoAssert = true);

Parameters

Hour, Minute, Second Indicates a hour, minute and second values.

st A Win32 SYSTEMTIME structure.

ltod Indicates an existing CLLTimeOfDay instance.

TotalSeconds Indicates a accumulated number of seconds.

bDoAsserts if set, the constructors will assert in debug mode if any of the parameters are invalid

Remarks

 

CLLTimeOfDay Set functions

CLLTimeOfDay& Set();

CLLTimeOfDay& Set(uint16_t Hour, uint16_t Minute, double Second, bool bDoAssert = true);

CLLTimeOfDay& Set(const SYSTEMTIME& st, bool bDoAssert = true);

CLLTimeOfDay& Set(double TotalSeconds, bool bDoAssert = true);

Parameters

See CLLTimeOfDay Constructors

Remarks

 

static CLLTimeOfDay CLLTimeOfDay::CurrentSystemTime();

Returns a CLLTimeOfDay which represents the current UTC time of day as taken from the system clock.

 

static CLLTimeOfDay CLLTimeOfDay::CurrentLocalTime();

Returns a CLLTimeOfDay which represents the current Local time of day as taken from the system clock.

 

static CLLTimeOfDay CLLTimeOfDay::Midnight();

Returns a CLLTimeOfDay that represents midnight.

 

static CLLTimeOfDay CLLTimeOfDay::Midday();

Returns a CLLTimeOfDay that represents midday.

 

static String CLLTimeOfDay::GetAMString();

Returns the string to used for the 'AM' indicator for the current user locale.

 

static String CLLTimeOfDay::GetPMString();

Returns the string to used for the 'PM' indicator for the current user locale.

 

uint16_t CLLTimeOfDay::GetHours() const;

Returns the number of hours this CLLTimeOfDay contains.

e.g. CLLTimeOfDay<> x(12 , 13, 14, 15)

assert(x.GetHours() == 12);

 

uint16_t CLLTimeOfDay::GetMinutes() const;

Returns the number of minutes this CLLTimeOfDay contains.

e.g. CLLTimeOfDay<> x(12 , 13, 14, 15)

assert(x.GetMinutes() == 13);

 

double CLLTimeOfDay::GetSeconds() const;

Returns the number of seconds this CLLTimeOfDay contains.

e.g. CLLTimeOfDay<> x(12 , 13, 14, 15)

assert(x.GetSeconds() == 14);

 

uint32_t CLLTimeOfDay::GetTotalSeconds() const;

Returns the total number of seconds this CLLTimeOfDay contains.

e.g. CLLTimeOfDay<> x(0 , 1, 14, 15)

assert(x.GetTotalSeconds() == 74);

 

uint16_t  CLLTimeOfDay::GetAMPMHours() const;

Returns the 12 hour version of the hour this CLLTimeOfDay represents.

e.g. CLLTimeOfDay<> x(17 , 13, 14, 15)

assert(x.GetAMPMHour() == 5);

 

String CLLTimeOfDay::GetAMPMString() const;

Returns the string to used for the 'AM'or 'PM' indicator for the current user locale for this instance's hour value.

 

bool CLLTimeOfDay::IsValid() const;

Returns true if this instance is valid otherwise false.

e.g. CLLTimeOfDay<> Inval;

assert(IsValid(Inval) == false);

  

bool CLLTimeOfDay::GetAsSystemTime(SYSTEMTIME& SystemTime) const;

Returns a SYSTEMTIME structure representing this CLLTimeOfDay

Remarks

 

CLLTimeOfDay& CLLTimeOfDay::operator=(const CLLTimeOfDay& Tod);

Copies a CLLTimeOfDay into this CLLTimeOfDay instance and returns a reference to this instance.

 

CLLTimeOfDay CLLTimeOfDay::operator+(const CLLTimeSpan& TimeSpan) const;

CLLTimeOfDay CLLTimeOfDay::operator-(const CLLTimeSpan& TimeSpan) const;

Standard arithmetic operators to add and subtracts CLLTimeOfDay’s.

 

CLLTimeOfDay& CLLTimeOfDay::operator+=(const CLLTimeSpan& TimeSpan);

CLTimeSpan& CLLTimeOfDay::operator-=(CLLTimeSpan& TimeSpan);

Standard arithmetic auto increment and decrement operators.

 

bool CLLTimeOfDay::operator==(const CLLTimeOfDay& Tod) const;

bool CLLTimeOfDay::operator>(const CLLTimeOfDay& Tod) const;

bool CLLTimeOfDay::operator>=(const CLLTimeOfDay& Tod) const;

bool CLLTimeOfDay::operator<(const CLLTimeOfDay& Tod) const;

bool CLLTimeOfDay::operator<=(const CLLTimeOfDay& Tod) const;

bool CLLTimeOfDay::operator!=(const CLLTimeOfDay& Tod) const;

Standard arithmetic equality operators.

 

String CLLTimeOfDay::Format(const String& sFormat) const;

Generates a formatted string that corresponds to this CLLTimeOfDay object.

The sFormat string supports the following replaceable parameters:

Remarks

 

void CLLTimeOfDay::Serialize(CArchive& ar);

Standard MFC override to allow streaming of this CLLTimeOfDay to archive. The space taken is exactly 10 bytes (8 data bytes + 2 schema bytes).

 

friend CArchive& operator<<(CArchive& ar, CLLTimeSpan& Tod);

Simply calls the Serialize method of ‘Tod’, asserting that the archive ‘ar’ is storing.

 

friend CArchive& operator>>(CArchive& ar, CLLTimeSpan& Tod);

Simply calls the Serialize method of ‘Tod’, asserting that the archive ‘ar’ is loading.

 

 

 

CLDate Index

Constructors

CCLDate

Setting

Set

Static Constructors

CurrentSystemTime

CurrentLocalTime

Operations

GetCDate

GetCLTimeOfDay

GetDate

GetAsSystemTime

GetAsFileTime

GetAsCOleDateTime

GetAsTM

AddYear

AddMonth

AddWeek

IsValid

Overloaded Arithmetic Operators

operator=

operator+,-

operator+=.-=

operator++

operator--

Overloaded Equality Operators

operator==, > etc.

Display

GetWindowsFormatString

Format

Serialization

Serialize

operator<<

operator<<

 

 

CLDate Constructors

CLDate();

CLDate(int32_t Year, uint16_t month, uint16_t Day, uint16_t Hour, uint16_t Minute, uint16_t Second, bool bDoAssert = true);

CLDate(const SYSTEMTIME& SystemTime, bool bDoAssert = true);

CLDate(const FILETIME& FileTime, bool bDoAssert = true);

CLDate(int32_t Year, uint16_t month, uint16_t WeekOfMonth, DayOfWeek dow, uint16_t Hour, uint16_t Minute, uint16_t Second, bool bDoAssert = true);

CLDate(int32_t Days, CDate::DateEpoch e, uint16_t Hour, uint16_t Minute, uint16_t Second, bool bDoAssert = true);

CLDate(const CLDate& ld);

CLDate(const CTime& ctime, bool bDoAssert = true);

CLDate(const CDate<TCALENDAR>& Date, const CLTimeOfDay& Tod);

CLDate(const COleDateTime& oleTime, bool bDoAssert = true);

Parameters

Year, Month, Day Indicates a year, month and day.

Hour, Minute, Second Indicates a hour, minute and second values.

SystemTime A Win32 SDK SYSTEMTIME structure.

FileTime A Win32 SDK FILETIME structure.

ld Indicates a CLDate object that already exists.

ctime Indicates a CTime object that already exists.

WeekOfMonth The week of the month (0 - 5).

DayOfWeek The day of the week e.g. CDate::Sunday.

oleTime An OLE Date.

bDoAsserts if set, the constructors will assert in debug mode if any of the parameters are invalid

Remarks

 

CLDate Set functions

CLDate& Set();

CLDate& Set(int32_t Year, uint16_t month, uint16_t Day, uint16_t Hour, uint16_t Minute, uint16_t Second, bool bDoAssert = true);

CLDate& Set(const SYSTEMTIME& st, bool bDoAssert = true);

CLDate& Set(const FILETIME& FileTime, bool bDoAssert = true);

CLDate& Set(int32_t Year, uint16_t month, uint16_t WeekOfMonth, DayOfWeek dow, uint16_t Hour, uint16_t Minute, uint16_t Second, bool bDoAssert = true);

CLDate& Set(int32_t Days, CDate::DateEpoch e, uint16_t Hour, uint16_t Minute, uint16_t Second, bool bDoAssert = true);

CLDate& Set(const CTime& ctime, bool bDoAssert = true);

CLDate& Set(const CDate<TCALENDAR>& Date, const CLTimeOfDay& Tod);

CLDate& Set(const COleDateTime& oleTime, bool bDoAssert = true);

Parameters

See CLDate Constructors

Remarks

 

static CLDate CLDate::CurrentSystemTime(bool bDoAssert = true);

Returns a CLDate which represents the current UTC date as taken from the system clock.

 

static CLDate CLDate::CurrentLocalTime(bool bDoAssert = true);

Returns a CLDate which represents the current local date as taken from the system clock.

 

CDate<TCALENDAR> CLDate::GetCDate() const;

Returns a CDate that represents the date part of this instance. Allows co-ordinated access to all the range of CDate functions.

Remarks

 

CLTimeOfDay<> CLDate::GetCLTimeOfDay() const;

Returns a CLTimeOfDay that represents the time of day part of this long date. Allows co-ordinated access to all the range of CLTimeOfDay functions.

Remarks

 

DateLS CLDate::GetDate() const;

Returns a DateLS structure for this instance.

 

bool CLDate::GetAsSystemTime(SYSTEMTIME& SystemTime) const;

Returns a Win32 SDK SYSTEMTIME struct version of this instance if this method succeeds by returning true.

Remarks

 

bool CLDate::GetAsFileTime(FILETIME& FileTime) const;

Returns a Win32 SDK FILETIME struct version of this instance if this method succeeds by returning true.

 

bool CLDate::GetAsCOleDateTime(COleDateTime& OleDateTime) const;

Returns a COleDateTime representation of this instance if this method succeeds by returning true. This may prove useful in environments where you have to integrate with VB, ODBC or DAO.

 

bool CLDate::GetAsTM(tm& time);

Returns a ‘C’ runtime tm struct version of this instance if this method succeeds by returning true.

 

void CLDate::AddYear(int Years = 1);

Adds a number of years to this instance.

 

void CLDate::AddMonth(int Months = 1);

Adds a number of months to this instance.

Remarks

 

void CLDate::AddWeek(int Weeks = 1);

Adds a number of weeks i.e. 7 days to this instance.

 

bool CLDate::IsValid() const;

Returns true if this instance is valid otherwise false.

e.g. CLDate Inval;

assert(IsValid(Inval) == false);

 

CLDate& CLDate::operator=(const CLDate& ld);

Copies a CLDate into this CLDate and returns a reference to this instance.

 

CLDate CLDate::operator+(const CLTimeSpan& ts);

CLTimeSpan CLDate::operator-(const CLDate& ld);

CLDate CLDate::operator-(const CLTimeSpan& ts);

Standard arithmetic operators to add and subtracts CLDate’s.

 

CLDate& CLDate::operator+=(const CLTimeSpan& ts);

CLDate& CLDate::operator-=(const CLTimeSpan& ts);

Standard auto increment and decrement operators.

 

CLDate& CLDate::operator++();

Standard arithmetic increment operator. Adds one day to this instance

 

CLDate& CLDate::operator--();

Standard arithmetic decrement operator. Subtracts one day from this instance.

 

bool CLDate::operator==(const CLDate& ld);

bool CLDate::operator>(const CLDate& ld);

bool CLDate::operator>=(const CLDate& ld);

bool CLDate operator<(const CLDate& ld);

bool CLDate operator<=(const CLDate& ld);

bool CLDate operator!=(const CLDate& ld);

Standard arithmetic equality operators.

 

String CLDate::GetWindowsFormatString(LPCWSTR lpLocaleName = LOCALE_NAME_USER_DEFAULT)

Returns a CLDate::Format string appropriate for the specified windows locale as specified by 'lpLocaleName'

See Also

CLDate::Format

 

String CLDate::Format(const String& sFormat) const;

Generates a formatted string that corresponds to this CLDate object.

The sFormat string supports the following replaceable parameters:

Remarks

See Also

CLDate::GetWindowsFormatString

 

void CLDate::Serialize(CArchive& ar);

Standard MFC override to allow streaming of this CLDate to archive. The space taken is exactly 11 bytes (9 data bytes + 2 schema bytes).

Remarks

As of v3 of DTime+, the serialization is not backward compatible with earlier versions.

 

friend CArchive& operator<<(CArchive& ar, CLDate& ld);

Simply calls the Serialize method of ‘ld’, asserting that the archive ‘ar’ is storing.

 

friend CArchive& operator>>(CArchive& ar, CLDate& ld);

Simply calls the Serialize method of ‘ld’, asserting that the archive ‘ar’ is loading.

 

 

 

CLLDate Index

Constructors

CCLLDate

Setting

Set

Static Constructors

CurrentSystemTime

CurrentLocalTime

Operations

GetCDate

GetCLLTimeOfDay

GetDate

GetAsSystemTime

GetAsFileTime

GetAsCOleDateTime

AddYear

AddMonth

AddWeek

IsValid

Overloaded Arithmetic Operators

operator=

operator+,-

operator+=.-=

operator++

operator--

Overloaded Equality Operators

operator==, > etc.

Display

GetWindowsFormatString

Format

Serialization

Serialize

operator<<

operator<<

 

 

CLLDate Constructors

CLLDate();

CLLDate(int32_t Year, uint16_t month, uint16_t Day, uint16_t Hour, uint16_t Minute, double Second, bool bDoAssert = true);

CLLDate(const SYSTEMTIME& SystemTime, bool bDoAssert = true);

CLLDate(const FILETIME& FileTime, bool bDoAssert = true);

CLLDate(int32_t Year, uint16_t month, uint16_t WeekOfMonth, DayOfWeek dow, uint16_t Hour, uint16_t Minute, double Second, bool bDoAssert = true);

CLLDate(int32_t Days, CDate::DateEpoch e, uint16_t Hour, uint16_t Minute, double Second, bool bDoAssert = true);

CLLDate(const CLLDate& ld);

CLLDate(const CTime& ctime, bool bDoAssert = true);

CLLDate(const CDate<TCALENDAR>& Date, const CLLTimeOfDay& Tod);

CLLDate(const COleDateTime& oleTime, bool bDoAssert = true);

Parameters

Year, Month, Day Indicates a year, month and day.

Hour, Minute, Second Indicates a hour, minute and second values.

SystemTime A Win32 SDK SYSTEMTIME structure.

FileTime A Win32 SDK FILETIME structure.

ld Indicates a CLLDate object that already exists.

ctime Indicates a CTime object that already exists.

WeekOfMonth The week of the month (0 - 5).

DayOfWeek The day of the week e.g. CDate::Sunday.

oleTime An OLE Date.

bDoAsserts if set, the constructors will assert in debug mode if any of the parameters are invalid

Remarks

 

CLLDate Set functions

CLLDate& Set();

CLLDate& Set(int32_t Year, uint16_t month, uint16_t Day, uint16_t Hour, uint16_t Minute, double Second, bool bDoAssert = true);

CLLDate& Set(const SYSTEMTIME& st, bool bDoAssert = true);

CLLDate& Set(const FILETIME& FileTime, bool bDoAssert = true);

CLLDate& Set(int32_t Year, uint16_t month, uint16_t WeekOfMonth, DayOfWeek dow, uint16_t Hour, uint16_t Minute, double Second, bool bDoAssert = true);

CLLDate& Set(int32_t Days, CDate::DateEpoch e, uint16_t Hour, uint16_t Minute, double Second, bool bDoAssert = true);

CLLDate& Set(const CTime& ctime, bool bDoAssert = true);

CLLDate& Set(const CDate<TCALENDAR>& Date, const CLLTimeOfDay& Tod);

CLLDate& Set(const COleDateTime& oleTime, bool bDoAssert = true);

Parameters

See CLLDate Constructors

Remarks

 

static CLLDate CLLDate::CurrentSystemTime(bool bDoAssert = true);

Returns a CLLDate which represents the current UTC date as taken from the system clock.

 

static CLLDate CLLDate::CurrentLocalTime(bool bDoAssert = true);

Returns a CLLDate which represents the current local date as taken from the system clock.

 

CDate<TCALENDAR> CLLDate::GetCDate() const;

Returns a CDate that represents the date part of this instance. Allows co-ordinated access to all the range of CDate functions.

Remarks

 

CLLTimeOfDay<> CLLDate::GetCLLTimeOfDay() const;

Returns a CLLTimeOfDay that represents the time of day part of this long date. Allows co-ordinated access to all the range of CLTimeOfDay functions.

Remarks

 

DateLLS CLLDate::GetDate() const;

Returns a DateLLS structure for this instance.

 

bool CLLDate::GetAsSystemTime(SYSTEMTIME& SystemTime) const;

Returns a Win32 SDK SYSTEMTIME struct version of this instance if this method succeeds by returning true.

Remarks

 

bool CLLDate::GetAsFileTime(FILETIME& FileTime) const;

Returns a Win32 SDK FILETIME struct version of this instance if this method succeeds by returning true.

 

bool CLLDate::GetAsCOleDateTime(COleDateTime& OleDateTime) const;

Returns a COleDateTime representation of this instance if this method succeeds by returning true. This may prove useful in environments where you have to integrate with VB, ODBC or DAO.

 

void CLLDate::AddYear(int Years = 1);

Adds a number of years to this instance.

 

void CLLDate::AddMonth(int Months = 1);

Adds a number of months to this instance.

Remarks

 

void CLLDate::AddWeek(int Weeks = 1);

Adds a number of weeks i.e. 7 days to this instance.

 

bool CLLDate::IsValid() const;

Returns true if this instance is valid otherwise false.

e.g. CLLDate Inval;

assert(IsValid(Inval) == false);

 

CLLDate& CLLDate::operator=(const CLLDate& ld);

Copies a CLLDate into this CLLDate and returns a reference to this instance.

 

CLLDate CLLDate::operator+(const CLTimeSpan& ts);

CLTimeSpan CLLDate::operator-(const CLLDate& ld);

CLLDate CLLDate::operator-(const CLTimeSpan& ts);

Standard arithmetic operators to add and subtracts CLLDate’s.

 

CLLDate& CLLDate::operator+=(const CLTimeSpan& ts);

CLLDate& CLLDate::operator-=(const CLTimeSpan& ts);

Standard auto increment and decrement operators.

 

CLLDate& CLLDate::operator++();

Standard arithmetic increment operator. Adds one day to this instance

 

CLLDate& CLLDate::operator--();

Standard arithmetic decrement operator. Subtracts one day from this instance.

 

bool CLLDate::operator==(const CLLDate& ld);

bool CLLDate::operator>(const CLLDate& ld);

bool CLLDate::operator>=(const CLLDate& ld);

bool CLLDate operator<(const CLLDate& ld);

bool CLLDate operator<=(const CLLDate& ld);

bool CLLDate operator!=(const CLLDate& ld);

Standard arithmetic equality operators.

 

String CLLDate::GetWindowsFormatString(LPCWSTR lpLocaleName = LOCALE_NAME_USER_DEFAULT)

Returns a CLLDate::Format string appropriate for the specified windows locale as specified by 'lpLocaleName'

See Also

CLLDate::Format

 

String CLLDate::Format(const String& sFormat) const;

Generates a formatted string that corresponds to this CLLDate object.

The sFormat string supports the following replaceable parameters:

Remarks

See Also

CLLDate::GetWindowsFormatString

 

void CLLDate::Serialize(CArchive& ar);

Standard MFC override to allow streaming of this CLLDate to archive. The space taken is exactly 11 bytes (9 data bytes + 2 schema bytes).

 

friend CArchive& operator<<(CArchive& ar, CLLDate& ld);

Simply calls the Serialize method of ‘ld’, asserting that the archive ‘ar’ is storing.

 

friend CArchive& operator>>(CArchive& ar, CLLDate& ld);

Simply calls the Serialize method of ‘ld’, asserting that the archive ‘ar’ is loading.

 

 

 

Structures / Enums / Consts used by the Classes

namespace DTimePlus
{
enum Month
{
January = 1,
February = 2,
March = 3,
April = 4,
May = 5,
June = 6,
July = 7,
August = 8,
September = 9,
October = 10,
November = 11,
December = 12
};

enum MoslemMonth
{
Muharram = 1,
Safar = 2,
Rabi_Al_Awwal = 3,
Rabi_Ath_Thani = 4,
Jumada_l_Ula = 5,
Jumada_Ath_Tania = 6,
Rajab = 7,
Sha_ban = 8,
Ramdadan = 9,
Shawwal = 10,
Dhu_l_Qa_da = 11,
Dhu_l_Hijja = 12
};

enum DayOfWeek
{
Sunday = 1,
Monday = 2,
Tuesday = 3,
Wednesday = 4,
Thursday = 5,
Friday = 6,
Saturday = 7,
FirstDayOfWeek = Sunday,
LastDayOfWeek = Saturday
};

enum DateEpoch
{
EPOCH_JD = 0,
EPOCH_MJD = 1,
EPOCH_1900 = 2,
EPOCH_1950 = 3,
EPOCH_CTIME = 4,
EPOCH_2000 = 5,
EPOCH_GREG = 6
};

struct DateS
{
int32_t Year;
uint16_t Month;
uint16_t Day;
};

struct DateLS
{
int32_t Year;
uint16_t Month;
uint16_t Day;
uint16_t Hour;
uint16_t Minute;
uint16_t Second;
};

struct DateLLS
{
int32_t Year;
uint16_t Month;
uint16_t Day;
uint16_t Hour;
uint16_t Minute;
double Second;
};



}; //namespace DTimePlus

 

Remarks

 

 

 

UI Support

The UI support for DTime+ is provided by the DTime+UI.h module. This support is currently limited to MFC on Visual C compilers. This provides a collection of standard DDX functions to allow a date to be mapped to a CDate<CGregorianCalendar> instance and a time of day to be mapped to a CLTimeOfDay instance. To provide data entry for CLDate, you should provide 2 UI controls, one for the CDate component and another for the CLTimeOfDay component. Note that no UI support is currently provided for the CLTimeSpan class or the Julian or Moslem calendars. For this you will need to roll your own by using something like a standard edit control or a masked edit control. The UI used for both of these DDX functions uses the standard Date Time control as provided by Windows (and as wrapped by MFC with CDateTimeCtrl).

 

Usage of the Data entry Routines

 

Methods

DDX_DateTimeCtrl

 

void DDX_DateTimeCtrl(CDataExchange* pDX, int nIDC, DTimePlus::CDate<CGregorianCalendar>& value);

void DDX_DateTimeCtrl(CDataExchange* pDX, int nIDC, DTimePlus::CLTimeOfDay<>& value);

Depending on the overloaded function called, it transfers a CDate or CLTimeOfDay to and from the screen. This function would normally be called in your classes DoDataExchange function

Parameters

pDX Standard MFC data exchange class.

nIDC The resource ID of the date and time picker control associated with the member variable.

value Value to retrieve/set in the UI.

Remarks

 

 

 

Contacting the Author

PJ Naughter
Email: pjna@naughter.com
Web: http://www.naughter.com
30 October 2023