問題描述
是否有適用于 Windows 的 strptime()
的等效實現?不幸的是,這個 POSIX 函數似乎不可用.
Is there a good equivalent implementation of strptime()
available for Windows? Unfortunately, this POSIX function does not appear to be available.
strptime 的開放組描述 - 總結:它轉換文本將"MM-DD-YYYY HH:MM:SS"
等字符串轉化為tm struct
,與strftime()
相反.>
Open Group description of strptime - summary: it converts a text string such as "MM-DD-YYYY HH:MM:SS"
into a tm struct
, the opposite of strftime()
.
推薦答案
strptime()
的開源版本(BSD 許可)可以在這里找到:http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/time/strptime.c?rev=HEAD
An open-source version (BSD license) of strptime()
can be found here: http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/time/strptime.c?rev=HEAD
您需要添加以下聲明才能使用它:
You'll need to add the following declaration to use it:
char *strptime(const char * __restrict, const char * __restrict, struct tm * __restrict);
這篇關于strptime() 在 Windows 上等價?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!