dabadaba
dabadaba

Reputation: 9512

When could mktime return -1?

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?

Upvotes: 1

Views: 139

Answers (1)

James Kanze
James Kanze

Reputation: 153909

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.

Upvotes: 1

Related Questions