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 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



Comments

  • TimeStamp::setDateTime fix

    Posted by justus on 08/12/2014 12:18am

    Hi, Thank you for your TimeStamp source code it has been very helpful to me. However there is an error in: void TimeStamp::setDateTime(long year, long month, long day, long hour, long minute, long second ) { // convert to sys time SYSTEMTIME sysTime; sysTime.wYear = year; sysTime.wMonth = minute; /*

    Reply
  • Bug in code...

    Posted by Legacy on 10/16/2003 12:00am

    Originally posted by: ron

    The setDateTime function used the minutes param as the month param....

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: December 11, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT Market pressures to move more quickly and develop innovative applications are forcing organizations to rethink how they develop and release applications. The combination of public clouds and physical back-end infrastructures are a means to get applications out faster. However, these hybrid solutions complicate DevOps adoption, with application delivery pipelines that span across complex hybrid cloud and non-cloud environments. Check out this …

  • CentreCorp is a fully integrated and diversified property management and real estate service company, specializing in the "shopping center" segment, and is one of the premier retail service providers in North America. Company executives travel a great deal, carrying a number of traveling laptops with critical current business data, and no easy way to back up to the network outside the office. Read this case study to learn how CentreCorp implemented a suite of business continuity services that included …

Most Popular Programming Stories

More for Developers

RSS Feeds