سؤال

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