implot icon indicating copy to clipboard operation
implot copied to clipboard

replace older time functions with more portable ones

Open Gargaj opened this issue 1 year ago • 5 comments

As per https://www.gnu.org/software/libc/manual/html_node/Broken_002ddown-Time.html

Gargaj avatar May 17 '24 14:05 Gargaj

@Gargaj I think your code is missing an important step:

Portability note: mktime is essentially universally available. timegm is rather rare. For the most portable conversion from a UTC broken-down time to a simple time, set the TZ environment variable to UTC, call mktime, then set TZ back.

epezent avatar Dec 24 '24 14:12 epezent

This has been a while so I don't specifically remember what was being broken, but the functions I was trying to fix were not available on one of the current generation consoles.

Gargaj avatar Dec 24 '24 17:12 Gargaj

I am encountering the same issue as @Gargaj, and the platform in question does not support time zone setting via functions like tzset().

I was able to workaround by defining replacements for timgm and other functions before including implot.cpp, but it is a bit of a hack. Perhaps for robustness of the ImPlot API, a #define could be optionally provided to override implementation of the time related functions, to enable implementation sites to control behavior for specific platforms.

skarolewics avatar Feb 22 '25 01:02 skarolewics

@skarolewics Would you be able to share your replacement for timegm?

CA-Jon-Colverson avatar Sep 01 '25 11:09 CA-Jon-Colverson

@CA-Jon-Colverson I used the solution described here: https://stackoverflow.com/a/68761107

skarolewics avatar Sep 29 '25 17:09 skarolewics