gpt4 book ai didi

C++:如何将日期字符串转换为 int

转载 作者:塔克拉玛干 更新时间:2023-11-03 08:02:00 24 4
gpt4 key购买 nike

您好,我需要一个将字符串时间转换为 int 的过程。在 unix 下支持所有这些格式:

 "Wed, 09 Feb 1994 22:23:32 GMT"       -- HTTP format
"Thu Feb 3 17:03:55 GMT 1994" -- ctime(3) format
"Thu Feb 3 00:00:00 1994", -- ANSI C asctime() format
"Tuesday, 08-Feb-94 14:15:29 GMT" -- old rfc850 HTTP format
"Tuesday, 08-Feb-1994 14:15:29 GMT" -- broken rfc850 HTTP format

"03/Feb/1994:17:03:55 -0700" -- common logfile format
"09 Feb 1994 22:23:32 GMT" -- HTTP format (no weekday)
"08-Feb-94 14:15:29 GMT" -- rfc850 format (no weekday)
"08-Feb-1994 14:15:29 GMT" -- broken rfc850 format (no weekday)

"1994-02-03 14:15:29 -0100" -- ISO 8601 format
"1994-02-03 14:15:29" -- zone is optional
"1994-02-03" -- only date
"1994-02-03T14:15:29" -- Use T as separator
"19940203T141529Z" -- ISO 8601 compact format
"19940203" -- only date

"08-Feb-94" -- old rfc850 HTTP format (no weekday, no time)
"08-Feb-1994" -- broken rfc850 HTTP format (no weekday, no time)
"09 Feb 1994" -- proposed new HTTP format (no weekday, no time)
"03/Feb/1994" -- common logfile format (no time, no offset)

"Feb 3 1994" -- Unix 'ls -l' format
"Feb 3 17:03" -- Unix 'ls -l' format

"11-15-96 03:52PM" -- Windows 'dir' format

请问有什么建议吗?

最佳答案

我会仔细看看 Boost.Date_Time . Date-time input/output看起来像你想要的。

关于C++:如何将日期字符串转换为 int,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3882370/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com