TimeStamp - A replacement for COleDateTime and COleDateTimeSpan | CodeGuru

TimeStamp – A replacement for COleDateTime and COleDateTimeSpan

This is another COleDateTime and COleDateTimeSpan replacement class.  However, it differs in two ways: it isn’t dependent on MFC, and instead of using one class for date/time and another for date/time span, it unites the code into one class called TimeStamp. Like Chris Sells’ replacement, it was also started from the MFC version, and uses […]

Written By
CodeGuru Staff
CodeGuru Staff
Jul 6, 1999
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

This is another COleDateTime and COleDateTimeSpan replacement class.  However, it differs
in two ways: it isn’t dependent on MFC, and instead of using one class for date/time and another
for date/time span, it unites the code into one class called TimeStamp.

Like Chris Sells’ replacement, it was also started from the MFC version, and uses system calls for
dates and times.  However, internally, the class uses a method called getAsDouble to determine
whether an OLE DATE format is used or a double for the time span is used.  It incorporates all
the functionality of COleDateTime and COleDataTimeSpan, but it uses a small character to start the
method names.

An example of using the TimeStamp class is:

  // set start and end of time window
  TimeStamp start;
  start.getCurTimeStamp();
  TimeStamp end = start + TimeStamp::getdays (7);

There are static methods for returning a time interval, as in the above example, which
can then be added to another time stamp to produce an end time.

Lastly, there are several string methods for getting the date time as a string.  These
methods simplify usage so that you don’t have to pull up help for GetTimeFormat/GetDateFormat
to get the time as a string.

Download source – 5 KB    TimeStamp_src.zip

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.