阅读和写作日期与boost
reading and writing dates with boost
我正在尝试以以下格式读取/写入日期:yyyy-mm-dddThh:mm:ssZ
我在做这个:
boost::posix_time::ptime t = boost::posix_time::time_from_string( "2012-02-20T00:26:39Z" );
std::cout << boost::posix_time::to_iso_extended_string( t ) << std::endl;
如果我删除最后一个Z,它会起作用,但如果我保留它,就会抛出异常(错误的词法转换:源类型值不能被解释为目标)。
有没有更好的方法来处理这些日期,而不需要手动删除/添加Z?根据我在这里和那里读到的内容,我理解Z的意思是GMT,如果它不存在,就意味着时间在当地时区。我想要一些通用且无错误的版本来阅读它。
查看Boost.DateTime IO教程中关于格式化字符串的部分。
http://www.boost.org/doc/libs/1_48_0/doc/html/date_time/date_time_io.html#format_strings
我希望你能在那里找到答案。
相关文章:
- BOOST :: Gregorian ::日期在内部存储日期
- 比较日期c++(使用boost)
- 对于C++中的日期/时间库,是否有一种轻量级的Boost替代方案
- 在QuantLib的日期类和C++11 / boost Chrno上
- Boost,如何将以下字符串解析为日期/时间
- 阅读和写作日期与boost
- boost截止日期计时器在iOS中过期不准确
- boost截止日期计时器我的代码不能同时运行
- 在C++/boost中将日期时间转换为不同的时区
- 如何解析带有日期-时间+时间偏移的字符串到boost::posix_time::ptime
- 夏令时和其他时区相关的问题与boost日期时间库
- 使用sscanf作为boost日期
- c++ boost regex日期错误
- boost:: posix_time.如何在同一个应用程序中表示微秒和纳秒日期时间
- 使用to_iso_extended_string与boost日期
- Boost 1.53本地日期时间编译器错误使用-std=c++0x
- Boost日期时间捕获异常
- boost日期时间--输出格式
- Visual Studio 2012中Boost posix日期和时间的编译错误
- 如何使用boost::date_time从time_t中获取本地日期时间