C++ function that converts time(NULL) to local time -
in c++ i'm writing function converts time(null), seconds since january 1, 1970 in utc time, local time est in military time format (hours:minutes:seconds). i'm stumped how mathematically program stays accurate time moves forward.
also i'm aware there local time function i'd build function ground up. have advice or tips?
also i'm aware there local time function i'd build function ground up. have advice or tips?
why want when there plenty of free , well-tested packages? mentioned in comments, getting daylight savings time correct non-trivial. existing packages that, , right, based on iana tzinfo database.
c options:
std::localtime()
. function uses global variable; not thread safe.localtime_r()
. posix function , not part of c++ library. not exist on windows.localtime_s()
. optional c11 function. if exists on machine, might not part of<ctime>
.
c++ options:
boost date-time, https://github.com/boostorg/date_time .
howard hinant's date-time module, https://github.com/howardhinnant/date .
Comments
Post a Comment