R
R
Rockman2016-05-14 01:19:10
C++ / C#
Rockman, 2016-05-14 01:19:10

Why does mktime never return -1?

I convert the struct tm structure to time_t with the mktime function , which should return -1 if the values ​​are incorrect. But in my case, this does not happen, that is, even if I specify tm_mday = 32, then mktime will not return -1, but will return the number of seconds, but already from the first day of the next month, if we translate seconds into human form.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MiiNiPaa, 2016-05-14
@MiiNiPaa

Incorrect = does not fit into time_t. Everything else is correct, mktime will correct values ​​that go beyond normal limits. Read the manuals carefully.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question