문제

I saw this in the mktime cppreference:

Time since epoch as a std::time_t object on success or -1 if time cannot be represented as a std::time_t object.

And I started wondering when would this happen. Could anyone give an example where mktime returned -1?

도움이 되었습니까?

해결책

The time_t can only represent a finite interval, at least on any system I've seen. If the date you request is outside that interval (say tm_year equal to 250 on a Unix machine with a 32 bit time_t), then mktime will return -1.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top