DTime is a collection of classes & functions designed to ease the MFC 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, you decided they did not meet your requirements. And you wanted to write your own super-duper date and time classes, but deadlines were looming, then look no further. Included in this distribution is DTime v2.2 which is for 32 bit Windows only and requires MFC to use.
All source code is supplied for debugging / inspection.
The code is portable between the following platforms: Win32 (Windows 95), Win32 (NT) and Win32 (NT Unicode).
DTime is compatible with and has been tested with the following compilers VC 4.0, VC 4.1, VC 4.2 (flat), VC 4.2b and VC 5.
The package has been translated to German and this distribution can be used in both English and German environments.
The classes stick very closely to the MFC class structures and provide routines to map from CTime, COleDateTime, COleDateTimeSpan and CTimeSpan. Mappings are also available to convert to and from Win32 SDK date and time structures.
The classes do not rely on the C runtime library like CTime does. If you have used the CTime class then you will no doubt have come across its dependence on the environment variable TZ and all the problems that can give. The classes use of UTC / Local is much less vague than CTime which performs automatic mappings which can confuse even the most experienced developer.
A number of date / time classes are provided namely CDate, CLTimeSpan, CLTimeOfDay and CLDate.
A comprehensive set of classes and DDX and DDV routines which make use of the new spin controls, tabbed dialogs and new Windows 95 look and feel are also provided to connect to the user interface.
Tight integration with the Win32 NLSAPI. For example all the day of week and month strings are taken from Win32. This means that if DTime is used on an international version of Windows, the days of week etc. will be in the local language.
A control panel applet is provided to allow the date when the calendar systems were introduced in your country to be modified. The Win32 national language API does not provide this support so DTime augments this by adding its own support.
Format functions with a superset of the functionality provided by CTime/CTimeSpan::Format.
Overloaded versions of the Format functions are available to display a date or time according to display characteristics as specified in the control panel.
The CDate class provides a granularity of 1 day and uses a LONG to represent the count of days. Its range is valid for roughly the whole range of a LONG i.e. +/- 2 billion days from the current era.
The CLTimeOfDay class provides a granularity of 1 second.
The CLTimeSpan class provides a granularity of 1 second.
The CLDate class provides a granularity of 1 second. As with CDate, the full range of a LONG is valid. This is quite larger than the roughly 60-year time span for CTime and the 100 CE - 9999CE time span for COleDateTime.
All classes are fully Unicode enabled and can be built for NT Unicode.
All classes are fully enabled for translation by storing all strings as resources.
Classes fully support UTC (Universal Co-ordinated Time aka GMT), Local and ET (Ephemeris Time) time frames and includes functions to map between them.
Classes also fully support the two most common calendars in use, namely the Gregorian and Julian calendars. DTime also supports propalactive versions of these calendars and conversion between the two types.
29 October 2007
CLDate CLDate::operator+(const CLTimeSpan& TimeSpan)
{
if (IsValid() && TimeSpan.IsValid())
{
CLDate oldate
= *this;
//Because LOCAL Time is not a continous timeframe convert if necessary
//TimeFrame OldTF = GetTimeFrame();
if (GetTimeFrame() == LOCAL)
VERIFY(SetTimeFrame(UTC));
CLDate rVal;
rVal.m_nSeconds = m_nSeconds + TimeSpan.m_nSeconds;
rVal.m_TimeFrame = m_TimeFrame;
*this = oldate;
return rVal;
}
else
return CLDate();
}
This should be amended to read:
CLDate CLDate::operator+(const CLTimeSpan& TimeSpan)
{
if (IsValid() &&
TimeSpan.IsValid())
{
CLDate oldate = *this;
//Because LOCAL Time is not a continous timeframe convert if necessary
//TimeFrame OldTF = GetTimeFrame();
if (GetTimeFrame() == LOCAL)
VERIFY(SetTimeFrame(UTC));
CLDate rVal;
rVal.m_nSeconds = m_nSeconds + TimeSpan.m_nSeconds;
rVal.m_TimeFrame = m_TimeFrame;
rVal.m_bInGregCalendar
= m_bInGregCalendar;
*this = oldate;
return rVal;
}
else
return CLDate();
}
Since DTime is no longer being actively developed by myself, you should add the line in red above to your local source copy of the DTime module "datetime.cpp". This fixes an issue where the returned CLDate instance from this method was always in the non Gregorian calendar. Thanks to Johan Lorre for reporting this bug.
22 April 2006
11 April 2000
v2.22 (14 May 1999)
v2.21 (17 July 1998)
v2.2 (5 August 1997)