I need to convert dates before 1970 to timestamps. I have a correct tm structure but Microsoft's std library mktime can't convert it to negative timestamps. Is there any standard way (no Qt, WinAPI) to get it?
Asked
Active
Viewed 185 times
0
-
have you tried to use std::chrono? i recommend using this header only library in addition to it. https://github.com/HowardHinnant/date/blob/master/include/date/date.h – agent_bean Nov 20 '19 at 16:09
-
I tried to find a way using chrono, but failed. How can I use it with tm? – Андрей Чистобаев Nov 20 '19 at 16:10
-
https://stackoverflow.com/questions/16773285/how-to-convert-stdchronotime-point-to-stdtm-without-using-time-t – agent_bean Nov 20 '19 at 16:14
-
So your advice is to use days_from_civil function? – Андрей Чистобаев Nov 20 '19 at 16:19
-
look for howard hinnant on youtube he has really good examples on how to use std::chrono, and date time manipulation. – agent_bean Nov 20 '19 at 16:24
-
Could you post the answer (want mark it as solution)? – Андрей Чистобаев Nov 20 '19 at 16:36
-
Good answer. ;-) Question: Are your input dates UTC, or associated with some time zone? – Howard Hinnant Nov 21 '19 at 13:25
-
UTC, all is working now. My hand written function somehow lost 29/02. Thanks for your videos, it is really helpful! – Андрей Чистобаев Nov 21 '19 at 13:40