Question:
Can you point me at or come up with a generic class that allows date manipulation and storage without running into OS-specific or February 29 or Y2K issues?
Answer:
The Standard Library’s date and time functions are declared in the
If you’re relying on the Standard Library’s functions, your code is immune to OS-specific, time-related bugs such as Feb29 or Y2K.
If you wish to compare two dates, use the difftime() function. For example:
#includetime_t now = time(0); // get current time time_t yestderday = now-(24*60*60);double diff_in_sec = difftime(now, yesterday);
You can either write a class that wraps these functions or use them directly. My advice is to avoid any non-standard date and time functions and classes because they tend to be inefficient and buggy.