You
disagree that modern C++ is friendly when manipulating time?
1 2
|
auto today = std::chrono::system_clock::now();
auto tomorrow = today + 24h;
|
isn’t as friendly as
1 2
|
time_t today = time(0);
auto tomorrow = today + 24*60*60;
|
? Because they look very alike to me.
See, simple examples mean nothing. It is when you get down into the details that C++ makes life a little nicer to look at. Click through the “date” links to get an idea of what the differences are, and maybe learn something useful.
RE: same functionality
Um, yes?
The stuff in <chrono> has the same functionality as the stuff in <ctime>
a priori — <chrono> is an explicit
wrapper for <ctime>.
RE: doesn’t compile on old stuff
So what? Get yourself a modern compiler.
If you are stuck with something old and you cannot update its libraries in any way, then you won’t care about cool modern abstractions anyway, and keep plugging along with the old stuff without the fancy abstractions.
The purpose of modern C++ is improved abstraction. With respect to date-time stuff, it means you can manipulate time_points with high abstractions instead of lots of code playing around with lots of lines of std::tm stuff.
RE: DST
Well, since <chrono> is a wrapper for <ctime>, and DST is a function of your system locale, the answer is the same for both: it depends. AFAIK, most systems properly handle DST with localtime().
Still not sure why suggesting using modern C++ was an issue.