久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何在 C++ 中構建 ISO 8601 日期時間?

How do I construct an ISO 8601 datetime in C++?(如何在 C++ 中構建 ISO 8601 日期時間?)
本文介紹了如何在 C++ 中構建 ISO 8601 日期時間?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在使用 Azure REST API,他們正在使用它來創建表存儲的請求正文:

I'm working with the Azure REST API and they are using this to create the request body for table storage:

DateTime.UtcNow.ToString("o")

產生:

2012-03-02T04:07:34.0218628Z

2012-03-02T04:07:34.0218628Z

它被稱為往返",顯然它是一個 ISO 標準(參見 http://en.wikipedia.org/wiki/ISO_8601) 但我不知道如何在閱讀 wiki 文章后復制它.

It is called "round-trip" and apparently it's an ISO standard (see http://en.wikipedia.org/wiki/ISO_8601) but I have no idea how to replicate it after reading the wiki article.

有誰知道 Boost 是否支持這個,或者可能 Qt?

Does anyone know if Boost has support for this, or possibly Qt?

推薦答案

如果到最接近秒的時間足夠精確,可以使用strftime:

If the time to the nearest second is precise enough, you can use strftime:

#include <ctime>
#include <iostream>

int main() {
    time_t now;
    time(&now);
    char buf[sizeof "2011-10-08T07:07:09Z"];
    strftime(buf, sizeof buf, "%FT%TZ", gmtime(&now));
    // this will work too, if your compiler doesn't support %F or %T:
    //strftime(buf, sizeof buf, "%Y-%m-%dT%H:%M:%SZ", gmtime(&now));
    std::cout << buf << "
";
}

如果您需要更高的精度,可以使用 Boost:

If you need more precision, you can use Boost:

#include <iostream>
#include <boost/date_time/posix_time/posix_time.hpp>

int main() {
    using namespace boost::posix_time;
    ptime t = microsec_clock::universal_time();
    std::cout << to_iso_extended_string(t) << "Z
";
}

這篇關于如何在 C++ 中構建 ISO 8601 日期時間?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

What is the fastest way to transpose a matrix in C++?(在 C++ 中轉置矩陣的最快方法是什么?)
Sorting zipped (locked) containers in C++ using boost or the STL(使用 boost 或 STL 在 C++ 中對壓縮(鎖定)容器進行排序)
Rotating a point about another point (2D)(圍繞另一個點旋轉一個點 (2D))
Image Processing: Algorithm Improvement for #39;Coca-Cola Can#39; Recognition(圖像處理:Coca-Cola Can 識別的算法改進)
Sort list using STL sort function(使用 STL 排序功能對列表進行排序)
Is list::size() really O(n)?(list::size() 真的是 O(n) 嗎?)
主站蜘蛛池模板: 日韩和的一区二区 | 九九亚洲 | 精品久久中文 | 日本色综合 | 国产精品永久免费 | 国产精品毛片久久久久久久 | 一级免费看 | 国产成人免费视频网站高清观看视频 | 国产美女黄色 | 久久精品国产一区老色匹 | 五月激情婷婷网 | 中文字幕一区二区三区精彩视频 | 色婷婷一区二区三区四区 | 国产精品久久久久久久一区二区 | 拍真实国产伦偷精品 | 国产福利二区 | 日韩精品一区二区三区高清免费 | 精品欧美一区二区三区久久久 | 国产91在线 | 中日 | 亚洲日日夜夜 | caoporn视频在线| 国产欧美视频一区 | 精品欧美一区二区三区久久久 | 欧美久久精品一级黑人c片 91免费在线视频 | 无码一区二区三区视频 | 中文字幕一区二区三区不卡 | 一区二区三区视频 | 免费国产视频 | 久久久欧洲 | 亚洲第一网站 | 欧美精品一区二区免费 | 亚洲精品成人av | 欧美视频二区 | 久久国产欧美日韩精品 | 7777精品伊人久久精品影视 | 国产高潮av| 97精品超碰一区二区三区 | 精品国产1区2区3区 在线国产视频 | a级免费黄色片 | 久久高清 | 在线国产一区二区 |