. Home Feedback Contents Search

CTime 

Back Up Next

CTime

CTime is not a very complicated class. None the less, there are problems. First and foremost is exceeding data limits. A normal CTime only goes from x to y.

 

When constructing a CTime you can get confused as to the size of the components.

CTime ct = CTime( yr, mo, day, hr, min, sec, daylight_savings_time );

  • Year is a number like 2003.
  • Mo is a number of 1 to 12.
  • Day is a number of 1 to 31.
  • Hr is a number of 0 to 23.
  • Min is a number of 0 to 59.
  • Sec is a number of 0 to 59.
  • Daylight_savings_time has three values. 1 means yes, 0 means no and –1 means figure it out for me.

 

This can be confusing when converting into and out of struct tm which has a tendency to use a slightly different base numbering system where month is 0 to 11, year is relative to 1900 and so on.

 

Another little thing I ran into once was getting from GMT to local time.

 

<<add example of how to turn GMT time into local time>>

Back Up Next