Why is forward conversion from time_t
, equaled to 1, to tm
valid, whereas backward is not?
#include <ctime>
#include <map>
using namespace std;
int main() {
time_t timer = 1;
tm *timerSt = gmtime(&timer);
cout << asctime(timerSt) << endl; //Thu Jan 01 00:00:01 1970
timer = mktime(timerSt);
cout <<"timer 0: "<< timer << endl; //timer 0: -1
}