
It represents a relative time span as the name suggests and provides four constructors, one of which incorporates the ANSI time_t data type. The CTimeSpan class is used in conjunction with CTime to perform subtractions and additions. , 7=Sat // Operations // time mathĬTime operator-(CTimeSpan timeSpan) const ĬTime operator+(CTimeSpan timeSpan) const Ĭonst CTime& operator+=(CTimeSpan timeSpan) Ĭonst CTime& operator-=(CTimeSpan timeSpan) ĬString FormatGmt(LPCTSTR pFormat) const įriend CDumpContext& AFXAPI operator>(CArchive& ar, CTime& rtime) Int GetDayOfWeek() const // 1=Sun, 2=Mon. Int GetMonth() const // month of year (1 = Jan) int GetDay() const // day of month int GetHour() const Struct tm* GetLocalTm( struct tm* ptm = NULL) const īOOL GetAsSystemTime(SYSTEMTIME& timeDest) const Attributes struct tm* GetGmtTm( struct tm* ptm = NULL) const Constructors static CTime PASCAL GetCurrentTime() ĬTime( int nYear, int nMonth, int nDay, int nHour, int nMin, int nSec,ĬTime(WORD wDosDate, WORD wDosTime, int nDST = -1) ĬTime( const SYSTEMTIME& sysTime, int nDST = -1) ĬTime( const FILETIME& fileTime, int nDST = -1) Ĭonst CTime& operator=( const CTime& timeSrc) You can find the definition of CTime class in afx.h header file and it is as follows: In addition, this class also overloads the +, -, =, =, > operators to provide many more useful features. It also has methods to get the time in SYSTEMTIME or FILETIME or GMT format. Create a time class using individual entries for year, month, day, hour, minute, and secondīy incorporating the ANSI time_t data type, the CTime class provides all the functionalities discussed above in section 1.Create a time class using a Win32 SYSTEMTIME or FILETIME.Create a time class using a dos date and time.Create a time class using a Standard Library time_t calender time.Microsoft provides 7 different constructors for the CTime class which amongst others, allows you to do the following: The CTime class is used to hold an absolute time and date. To do such calculations from an application, we can use CTime for storing the time, and CTimeSpan for the calculations. If you look at web sites like this one, you can check the possibilities covered in the code, for example, changing the date/time stamp of a file so it will show 7 and a half hours backward. While (Af圎xtractSubString(field,sVal,index,_T( ' ')))ĬTime dtTime(_ttoi(v), _ttoi(v), _ttoi(v), _ttoi(v), _ttoi(v), _ttoi(v) ) Void CChangeFileTimeDlg::parseXapTime(CStringA sOrgTaken, CTime& dtTaken) A Combobox is used to allow the user to make the selection among the above options. I will elaborate about the various attributes files have, which are date/time related in the next section, however, for the simplicity of this article, our program changes all of these attributes at once. Our application allows you to either state the extension of files searched for, the name (or part of it) but also to process only files having a certain date/time stamp. The Building Blocks Searching for Files Based on a Given Criteria Relative change of currently stamped date and time, for example: 7 and a half hours earlier ( 12:31AM will be adjusted to: 5:01PM).Fixed date and time, for example: 01:00.Requested change - which can be either:.Date related attributes to apply to - which can be either:.AVI, or all files within a certain date, or files which contain a certain string in their name). Query - what to look for (for example, all files ending with.For example: c:\ or c:\users\myuser\documents\ Path - where to look (will bring a path dialog box where the user can type or choose the start path to search).IntroductionĮven though there can be many occasions in which a program like the one I am about to introduce, can be useful, I originally developed it for the purpose of adjusting wrong time stamp of photos and videos, which are a result of incorrect settings or time zone in the camcorder or camera. That is when I decided to program such a tool myself. I then setup the time of the camcorder and the camera to the correct time and looked for a way to fix the incorrect time stamps of my photos and video files. I calculated the correct times of both video and photo files, adjusting their time stamp and happily found out that both occurred within the same time frame, so everything was OK. thinking my precious files were somehow deleted. That was the reason for the confusion, and I spent a lot of time checking backups, etc.

One was 7 hours and 36 minutes earlier and the other was 3 hours later. I then realized that our still camera (Nikon D5000) and camcorder (Sony) are both set up with the wrong time, each with a different wrong time.

I recently looked for photos and videos of an important event and couldn't understand why I can't find any video files, even though I recalled that my wife and my daughter took both photos and videos.
