Pergunta

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?

Foi útil?

Solução

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top