User forums > Using Code::Blocks

print variable address

<< < (2/2)

ToApolytoXaos:
Google is your friend for generic information, let alone about finding for you how printf() works.

http://man7.org/linux/man-pages/man3/printf.3.html

Mich:
My issue is not around printf by around mktime(). I do not anderstand why mktime() change the .tm_isdst during the 26oct-27oct night. If you ntry this code you will find that the difference is 25H instead of 24H. If I force the .tm_isdst to 0 before mktime() call, a reverse ctime() call does gives the correct answer for "winter" date...


--- Quote ---        struct tm tmbidon;
        time_t tbidon, myreference, tdiff;

        tmbidon.tm_isdst = -1;
        tmbidon.tm_year = 13 + 100;   // ref 1900
        tmbidon.tm_mon = 9; /* Months *since* january: 0-11 */
        tmbidon.tm_mday = 27;
        tmbidon.tm_hour = 9;
        tmbidon.tm_min = 40;
        tmbidon.tm_sec = 0;
        myreference = mktime(&tmbidon);

        tmbidon.tm_isdst = -1;
        tmbidon.tm_mday = 26;
        tbidon = mktime(&tmbidon);
        tdiff = myreference-tbidon;
        printf("diff %I64usec  %fH\n", (u64)tdiff, ((float)tdiff)/3600);
        printf("myreference %s", ctime(&myreference));
        printf("tbidon %s", ctime(&tbidon));


        tmbidon.tm_isdst = 0;
        tmbidon.tm_year = 13 + 100;   // ref 1900
        tmbidon.tm_mon = 9; /* Months *since* january: 0-11 */
        tmbidon.tm_mday = 27;
        tmbidon.tm_hour = 9;
        tmbidon.tm_min = 40;
        tmbidon.tm_sec = 0;
        myreference = mktime(&tmbidon);

        tmbidon.tm_isdst = 0;
        tmbidon.tm_mday = 26;
        tbidon = mktime(&tmbidon);
        tdiff = myreference-tbidon;
        printf("diff %I64usec  %fH\n", (u64)tdiff, ((float)tdiff)/3600);
        printf("myreference %s", ctime(&myreference));
        printf("tbidon %s", ctime(&tbidon));

--- End quote ---

Result:
diff 90000sec  25.000000H                     <= ???
myreference Sun Oct 27 09:40:00 2013
tbidon Sat Oct 26 09:40:00 2013
diff 86400sec  24.000000H
myreference Sun Oct 27 09:40:00 2013
tbidon Sat Oct 26 10:40:00 2013             <= ???

I agree that this not the appropriated forum and I will look for the coorect one.


ToApolytoXaos:
Mich, please respect the rules of this forum.

This is NOT a programming forum that teach people how to program, but rather to report possible bugs you might have detected in Code::Blocks, or suggest improvements on existing parts of IDE.

I'm sure you can use Google to find why mktime() is not working.

Navigation

[0] Message Index

[*] Previous page

Go to full version