implot icon indicating copy to clipboard operation
implot copied to clipboard

unixTimePoint x-axis only displays back to Jan 01 1970

Open dgm3333 opened this issue 4 years ago • 5 comments

Although unixTimePoint allows storage of dates from Dec 13 1901 to Jan 19 2038 the timeseries x-bar only displays back to Jan 01 1970 (ie back to zero, and not negative) - although it goes positive much greater than 2038 when int64 overflow will occur.

dgm3333 avatar May 22 '21 12:05 dgm3333

Thanks, I stupidly assumed negative timestamps would not work, but alas they do. Unfortunately, to get this working in ImPlot will take a bit more than simply changing the value of IMPLOT_MIN_TIME to be a negative value. I'll take a look in the near future.

epezent avatar May 23 '21 23:05 epezent

Just a note: If you are thinking of updating this it would be nice if those of us who use dd/mm/yy calendars could have the option of days before months in the graph (I'm not sure whether this will be an easy tweak).

dgm3333 avatar May 29 '21 11:05 dgm3333

We currently provide US date formatting and ISO8601 formatting. Try enabling ImPlotStyle::UseISO8601 and see if that's more comfortable for you,

epezent avatar Jun 03 '21 18:06 epezent

Sorry now have two issues in the thread

Unless I'm using it incorrectly I tried UseLocalTime and various attempts to force the locale but they didn't work [ But having dates in US format is hardly a disaster even if it is totally illogical :-) so not worth getting excited about ]

std::setlocale(LC_ALL, "en_GB.UTF-8");
std::setlocale(LC_ALL, ""); // for C and C++ where synced with stdio
std::locale::global(std::locale("")); // for C++

ImPlot::GetStyle().UseLocalTime = true;     // = axis labels will be formatted for your timezone when ImPlotAxisFlag_Time is enabled
ImPlot::GetStyle().UseISO8601 = true;     // = dates will be formatted according to ISO 8601 where applicable (e.g. YYYY-MM-DD, YYYY-MM, --MM-DD, etc.)

Incidentally, what's the invalid tag for? The Unix time_t data type that represents a point in time is, on many platforms, a signed integer, traditionally of 32 bits (but see below), directly encoding the Unix time number as described in the preceding section. Being 32 bits means that it covers a range of about 136 years in total. The minimum representable date is Friday 1901-12-13, and the maximum representable date is Tuesday 2038-01-19. One second after 03:14:07 UTC 2038-01-19 this representation will overflow. This milestone is anticipated with a mixture of amusement and dread—see year 2038 problem. In some newer operating systems, time_t has been widened to 64 bits. This expands the times representable by approximately 293 billion years in both directions, which is over twenty times the present age of the universe per direction.

dgm3333 avatar Jun 07 '21 22:06 dgm3333