Boost ptime:如何以浏览器在http请求的header内发送的方式格式化数据
Boost ptime: how to format data in a way browsers send inside headers of http requests?
我需要以这种方式格式化我的ptime Wed, 21 Jan 2004 19:51:30 GMT
如何使用boost做这样的事情?(所以它看起来像HTTP服务器Expires
和Last-Modified
和Date
响应头的数据格式)
#include <locale>
#include <string>
#include <iostream>
#include <sstream>
#include <boost/date_time/posix_time/posix_time.hpp>
std::string current_time_formatted()
{
namespace bpt = boost::posix_time;
static char const* const fmt = "%a, %d %b %Y %H:%M:%S GMT";
std::ostringstream ss;
// assumes std::cout's locale has been set appropriately for the entire app
ss.imbue(std::locale(std::cout.getloc(), new bpt::time_facet(fmt)));
ss << bpt::second_clock::universal_time();
return ss.str();
}
请参阅日期时间输入/输出以获得有关可用格式标志的更多信息。
相关文章:
- 将从格式化文本文件读取的文本数据存储到链表
- 如何在 c++ 中格式化和访问 2D 矢量数组中的数据
- 使用 std::locale 格式化法语数字时无效的 UTF-8 数据
- 二进制模式 + 格式化文本操作或文本模式 + 二进制数据操作 - 有意义吗?
- JavaScript "header"文件来存储一些数据
- 用C++读取带多个分隔符的格式化数据
- 使用c++只读取已格式化和未格式化数据的文件中的已格式化数据
- 正确格式化I2C的数据(Wire.write)
- 已知格式化文件中的数据排列
- 我可以告诉解决方案如何使用 C 写入此格式化数据
- C++ read() 返回未格式化的二进制数据
- 使用C++或任何windows脚本语言格式化文本数据
- 将格式化数据转换为结构的方便方法
- 比较包含格式化数据的字符串
- 在c++中读取格式化数据的最简单/最清晰的方法
- 使用 ifstream 提取运算符C++>>从文件中读取格式化数据
- c++字符串附加格式化数据
- 从大文件中读取格式化数据的最有效方法是什么
- 使用格式化数据的 fstream
- Boost ptime:如何以浏览器在http请求的header内发送的方式格式化数据