使用to_iso_extended_string与boost日期
using to_iso_extended_string with boost date
我正试图将d2转换为形式'2011-08-02'的字符串,因此我可以将其传递给我的sql语句。根据boost站点,to_iso_extended_string应该返回该格式,但我得到的却是以下内容:' 2011-08-02 '。
date today(day_clock::local_day());
date_duration dd(30);
date d2=today-dd;
std::string to_iso_extended_string(date d2);
如何将日期转换为yyyy-mm-dd格式的字符串
我刚刚测试了这个,它为我打印了2011-08-02
:
#include <iostream>
#include <string>
#include <boost/date_time.hpp>
namespace bg = boost::gregorian;
int
main ()
{
bg::date today (bg::day_clock::local_day());
bg::date_duration dd(30);
bg::date d2 = today - dd;
std::string str(to_iso_extended_string(d2));
std::cout << str << "n";
}
相关文章:
- 我正在将一个 std::string 传递给一个 boost 函数,该函数对该类型进行常量引用,但该值发生了变化
- 如何从 boost::container::vector<std::string>::iterator 访问索引和对象?
- std::string references、std::regex和boost::filesystem的基本概念
- 将 std::string 转换为 boost::asio::streambuf
- 使用 boost::interprocess 共享内存时从 std::string 转换为 "MyShmString"
- 当我使用py 生成时,然后在macOS上boost.python包装器时,我会发现有关std :: string的错
- 如何在 Boost.Sprit.Qi 中从向量制作组合的 ascii::string 规则<string>?
- boost-python 当C++方法返回 std::map<string,X*>
- 从 boost::存档:binary_iarchive 反序列化 std::string 时出现错误的分配异常
- 从 C 字符串构造 boost::type_erasure::any,但存储为 std::string
- boost::asio::async_write with std::string
- 如何将std :: string转换为boost :: chrono :: nanseconds
- 使用Boost Karma替换STD :: stringstream double到STD :: String Conv
- 无法获得 boost::spirit parser&lexer 适用于 std::string 或 int 或 double 以外的令牌类型
- `boost::local_time::date_time` from `std::string`
- 从STD :: String Boost C 获取小时和几分钟
- 将Boost STD :: String :: const_iterator转换为字符串和INT C
- 为什么 boost::assign::list_of 不适用于对字符串、矢量<string>><?
- 如何将 std::vector<std::string> 转换为 boost::spirit 中结构的成员?
- 从BOOST STRING返回某些字符