-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Input date modified when calling mktime64 #7
Comments
Could you provide a sample program that triggers the bug? Be sure to include the time zone you're in. |
Sure. #include <iostream>
#include "time64.h"
int main(int argc, char **argv) {
struct tm tt;
char buffer[64];
::strptime("1/1/2040 12.00.00", "%d/%m/%Y %H.%M.%S", &tt);
{
size_t len = ::strftime(buffer, sizeof(buffer), "%d/%m/%Y %H.%M.%S", &tt);
std::cout << "Input date: " << std::string(buffer, len) << std::endl;
}
::mktime64((struct TM *)&tt);
{
size_t len = ::strftime(buffer, sizeof(buffer), "%d/%m/%Y %H.%M.%S", &tt);
std::cout << "Correct date: " << std::string(buffer, len) << std::endl;
}
return 0;
} Output
Excuse but I have not understood where I have to include my time zone. I ran this code at CET, if you need to know. |
I haven't forgotten about this. I'm off learning a bunch of C so I can do a better job fixing up this project. LMK if there's urgency on getting this integrated. |
Same issue. |
FYI to workaround this issue, I just commented out the two lines in mktime64 which call copy_tm_to_TM64. Not sure why they are there to begin with but perhaps the author could opine on whether they should stay? If they should, then an alternative workaround would be to revert the year immediately after the second occurrence of copy_tm_to_TM64:
|
Congratulations for this great lib, solved me a sad moment.
I noticed mktime64 correct input_date, but leaving an incorrect year if date is not in safe range.
I modified sources, adding
after line 542 (copying safe_date on input_date) and it seems to work correctly.
Do you think it is acceptable?
Thank you for your job
-Cristiano
The text was updated successfully, but these errors were encountered: