【发布时间】:2010-11-26 14:38:58
【问题描述】:
我有以下 std::string '2010-08-10T23:59:00' 我需要将其转换为 boost::gregorian::date 对象。
我知道我应该使用boost::date_time::date_input_facet,但我似乎不知道该怎么做。
有人可以帮助我如何进行这种转换吗?
【问题讨论】:
我有以下 std::string '2010-08-10T23:59:00' 我需要将其转换为 boost::gregorian::date 对象。
我知道我应该使用boost::date_time::date_input_facet,但我似乎不知道该怎么做。
有人可以帮助我如何进行这种转换吗?
【问题讨论】:
boost 的 posix_time 模块支持从该格式直接转换(除非我很困惑,否则它是 ISO 时间格式?)。看看:
boost::posix_time::from_iso_string
你只需要先去掉格式标记。
posix_time::time_from_string
也可能对你有用。
您应该能够将 posix_time 转换为 gregorian。
希望这会有所帮助。
【讨论】: