久久久久久久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豆花视频 | 日韩视频精品 | 伊人91在线| 日本一区二区三区四区 | 久久国产精品久久国产精品 | 亚洲国产精品一区二区第一页 | 91视频一88av| 久久99精品久久久久久国产越南 | 亚洲人成人一区二区在线观看 | 久久小视频 | www.国产精品 | 久久aⅴ乱码一区二区三区 亚洲国产成人精品久久久国产成人一区 | 亚洲xxxxx| 成人免费在线视频 | 国产精品欧美一区二区三区不卡 | 亚洲图片视频一区 | 国产三级精品三级在线观看四季网 | www亚洲免费国内精品 | 黄色av观看 | 91资源在线播放 | 久久精品免费看 | 人人干人人玩 | 狠狠综合久久av一区二区老牛 | 日韩欧美精品在线 | 天天玩天天干天天操 | 日韩免费视频 | 欧美一区2区三区4区公司 | 国产高清在线视频 | 久久另类 | 国内精品久久久久久久影视简单 | h漫在线观看| 久久久夜色精品亚洲 | 97av视频在线观看 | 欧美日韩理论 | 在线观看成人精品 | 淫片专区 | 超碰520| 久久久久亚洲 |