Using Julian date+time values for such is preferred. That way, you can use simple value comparisons to see if one date+time is before/after another, and the conversions to standard date+time using local timezone settings is well documented. There are good documents in Wikipedia for that, and may be a number of open source C++ classes you can use. I wrote my own for a major C++ framework back in the 1990's (before there was such in the FOSS community) and it is working fine today, helping run most semiconductor FABs in the world.
Here is a class (.h and .cpp files) that I wrote for my own use. I am releasing it under a GPLv3 License. IE, you can use it freely, but if you modify it you must provide the modified (and original) source to users who request it.
#ifndef AFS_DATE_H
#define AFS_DATE_H
///////////////////////////////////////////////////////////
// Date.h
// Implementation of the Class Date
// Created on: 16-Nov-2006 4:23:49 PM
// Original author: William Boyle
///////////////////////////////////////////////////////////
#include <time.h>
#if defined(LINUX) || defined(CYGWIN)
#include <sys/time.h>
#endif
#include "AFS/BASE/Error.h"
namespace AFS
{
class InvalidDateError : public AfsError
{
public:
InvalidDateError() : AfsError(UtilitySection, InvalidDate) {}
InvalidDateError( const InvalidDateError& cpy ) : AfsError(cpy) {}
virtual ~InvalidDateError() throw (LiveObjectError) {}
InvalidDateError& operator=( const InvalidDateError& rhs )
{ if (this != &rhs) { AfsError::operator=(rhs); } return *this; }
};
/**
* getDateFromString() - if 'ptm' is nil, a local static structure will be returned.
* This can only be used in re-entrant code if a pointer …