How to convert std::chrono::time_point to std::tm without using time_t?

前端 未结 3 368
一个人的身影
一个人的身影 2020-12-31 04:41

I would like to print or extract year/month/day values.

I don\'t want to use time_t because of the year 2038 problem, but all examples I found on the In

3条回答
  •  Happy的楠姐
    2020-12-31 05:18

    There's nothing to support calendar dates in the Standard Library apart from the C library functions based on time_t.

    Options are, in order of my preference:

    • Boost.Date_Time, which you say you'd prefer to avoid
    • Some other third-party date/time library (I don't have an recommendations since I'd use Boost)
    • Modify an open-source implementation of gmtime()
    • Use this algorithm, after checking that it's correct.

提交回复
热议问题