Hello,I tried your programme on my system (other linux distribution), and got the same result;
even on windows the same results; but this is interesting # date --date="Dec 1 00:00:00 2019" +"%s" 1575154800 # date --date="Nov 30 23:59:59 2019" +"%s" 1575154799 there you have this 1 second difference; I'd say mktime seens to be buggy ... Walter On 18.12.2019 15:17, Jouk Jansen wrote:
Hi All, I'm strugling with the C-function mktime. According to the man-pages it returns "seconds since the Epoch". I tried to use this functions to get differnces from two date-times , but was could not interpret the result. When trying to get the diffrence between 30 Nov 2019 23:59:59 and 1 Dec 2019 00:00:00 (see code below) I expected to find 1 second difference but I find: 1577746799 1577833200 -86401 As output of the sample program. (and not 1577833199 1577833200 -1) How should I read "seconds since the Epoch"???? Is the output of mktime correct? (I also tried 31 Nov and got the expected 1 second) (should mktime not give an error for 31 Nov??) Regards Jouk Code : #include<stdio.h> #include<time.h> main() { struct tm time_str , time_str2; time_str.tm_sec = 59; //30 Nov 2019 23:59:59 time_str.tm_min = 59; time_str.tm_hour = 23; time_str.tm_mday = 30; time_str.tm_mon = 11; time_str.tm_year = 119; time_str.tm_isdst = 0; time_str2.tm_sec = 0; // 1 Dec 2019 00:00:00 time_str2.tm_min = 0; time_str2.tm_hour = 0; time_str2.tm_mday = 1; time_str2.tm_mon = 12; time_str2.tm_year = 119; time_str2.tm_isdst = 0; printf( "%d %d %d\n" , mktime(&time_str ) , mktime(&time_str2 ) , mktime(&time_str ) - mktime(&time_str2 ) ); }
Attachment:
smime.p7s
Description: S/MIME Cryptographic Signature
_______________________________________________ users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/users@xxxxxxxxxxxxxxxxxxxxxxx