'mktime causes overflow in SLES 15 SP3

SLES 15 SP3 makes use of glibc 2.31 and our convert time code using mktime is failing with ulong overflow. Can anyone let us know if we are missing something here. Or do we have any other alternative system call that does the same?

main()
{
    time_t time_since_epoch = 0;
    struct tm gmTimetm; 
    gmTimetm.tm_year = 2022;
    gmTimetm.tm_mon = 02;
    gmTimetm.tm_mday = 24;
    gmTimetm.tm_hour = 11;
    gmTimetm.tm_min = 42;
    gmTimetm.tm_sec = 45;
    time_since_epoch = mktime(&gmTimetm);

    printf("%lu \n", time_since_epoch);
    return 0; 
}

OP: 18446744073709551615



Solution 1:[1]

mktime() is failing. It is returning -1.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1