boost时间操作
2014-03-13 17:52
295 查看
#include "iostream" #include "boost/date_time.hpp" #include "boost/thread/thread.hpp" using namespace boost::gregorian; using namespace boost::posix_time; using namespace std; int main(){ //gregorian(公立) 日期类型 精确到天 //构造函数 date today(2014,3,12); date local_today(day_clock::local_day()); date universal_today(day_clock::universal_day()); //字符和日期之间的转换 cout << today << endl; cout << to_iso_string(today) << endl; cout << local_today << endl; cout << universal_today << endl; cout << "day_of_year:" << local_today.day_of_year() << endl; cout << "day_of_week:" << local_today.day_of_week() << endl; cout << "month:" << local_today.month() << endl; //日期计算 date tomorrow = today + date_duration(1); //最小单位1天 cout << "today:" << today << " tomorrow:" << tomorrow << endl; cout << from_string("2014/03/12") << endl; cout << from_undelimited_string("20130312") << endl; //posix_time 时间类型 能精确到微秒 //构造 ptime now(today,hours(18)+minutes(10)+seconds(0)); ptime local_now(second_clock::local_time()); cout << "now : " << now << " length:" << to_iso_string(now).length() << endl; cout << "local_now : " << local_now << endl; //遍历 time_iterator titr(now,hours(1)); for (; titr < now+hours(24); ++titr) { std::cout << (*titr) << std::endl; } return 0; }
相关文章推荐
- [Boost]boost的时间和日期处理-(2)时间的操作
- boost时间的操作
- [Boost]boost的时间和日期处理-(1)日期的操作
- [Boost]boost的时间和日期处理-(1)日期的操作
- boost日期、时间操作
- [Boost]boost的时间和日期处理日期的操作和时间的操作
- boost asio 串口操作中修改字节超时间隔参数
- [Boost]boost的时间和日期处理-(2)时间的操作
- Js获取当前日期时间及其它操作
- C++文件目录操作---opencv和boost例子
- cisco 交换机设置时区、时间、同步日志本地时间等操作
- Date类与GregorianCalendar类对时间的操作
- Java中有关日期的操作,昨天晚上赴约,搞到12点多才回来,今天写这一小段代码都花了一段漫长的时间,哎。。
- 软件开发时间操作全攻略
- 超时时间已到。在操作完成之前超时时间已过或服务器未响应
- iOS 本地时间 / UTC时间 / 时间戳等操作 / 获取当前年月日
- 时间的模拟操作
- Heap_delete(A,i)操作将结点i中的想从堆A中删去。对含n个元素的最大堆,请给出时间为O(lgn)的HEAP-DELETE的实现。
- 时间操作(Java版)—获取距离系统时间N天后的日期时间信息
- .net杂记 (调用EXE 获取路径 target VB DIV C# Split 页面之间传递值 更改session时间 EXCEL操作 控制电子邮件Mail input记录值的窍门)