Simplest way to get current time in current timezone using boost::date_time?

前端 未结 3 1116
误落风尘
误落风尘 2021-01-04 09:41

If I do date +%H-%M-%S on the commandline (Debian/Lenny), I get a user-friendly (not UTC, not DST-less, the time a normal person has on their wristwatch) time p

3条回答
  •  无人及你
    2021-01-04 10:42

    This does what I want:

      namespace pt = boost::posix_time;
      std::ostringstream msg;
      const pt::ptime now = pt::second_clock::local_time();
      pt::time_facet*const f = new pt::time_facet("%H-%M-%S");
      msg.imbue(std::locale(msg.getloc(),f));
      msg << now;
    

提交回复
热议问题