一见

boost日期、时间操作

#include <boost/date_time.hpp>


boost::posix_time::ptime now = boost::posix_time::from_time_t(time(NULL));

boost::posix_time::to_simple_string(now); // CCYY-mmm-dd hh:mm:ss.fffffff

boost::posix_time::to_iso_string(now); // YYYYMMDDTHHMMSS

boost::posix_time::to_iso_extended_string(now); // YYYY-MM-DDTHH:MM:SS


​#include <boost/thread/xtime.hpp>​


    void sleep(uint32_t seconds)
    {
        boost::xtime xt;
        boost::xtime_get(&xt, boost::TIME_UTC_);
        xt.sec += seconds;
        boost::thread::sleep(xt); // Sleep for 1 second
    }

posted on 2013-01-17 15:06  -见  阅读(232)  评论(0编辑  收藏  举报

导航