spdlog icon indicating copy to clipboard operation
spdlog copied to clipboard

daily file sink - daylight saving time

Open MarioPoneder opened this issue 6 years ago • 2 comments

Hello,

it seems like there is a problem with daylight saving time, because the method spdlog::sinks::daily_file_sink::next_rotation_tp_() just adds 24 hours on return.

Kind regards Mario

MarioPoneder avatar Sep 11 '18 12:09 MarioPoneder

I can't find a reliable and fast way to handle dst. mktime might fail detecting it, and it is not well defined what to do anyway if the rotation time is same as dst.

gabime avatar Sep 16 '18 20:09 gabime

I don't know if this has already been addressed in other issues, but with the addition of C++20's date time functionalities, std::chrono::time_zone's get_info() function returns a variable save which gives the daylight savings offset which could be helpful here. That being said, I'm not sure if this is worth looking into and providing a feature flag check to include or not based on C++20 requirements for this specific case, but the upside might be the fact that you would only have to pay the cost once initially and maybe whenever there was a check before rotating the log file.

The only other thing I can think of is bundling a form of Howard's date library with date/tz.h similar to how spdlog currently bundles a subsection of fmtlib, and optimizing some wrappers around the base calls that the C++20 additions call for the get_info().save variable, but I understand if adding dependencies is something that isn't wanted here.

It might take some time to do, especially as I'm still learning my way around programming as a whole, but I would be happy to try to put something together for this if either case sounds like a plausible solution? If not, I totally understand.

USAFrenzy avatar Apr 15 '22 16:04 USAFrenzy