我导入了下面的库。Linux:GetDateFormat()和GetTimeFormat()是否存在C++?
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
我想将代码下面的部分转换为Linux C++。怎么可能?
我已经转换TCHAR
到std::string
,这是在_countof
用作GetDateFormat
TCHAR szDate[16];
TCHAR szTime[16];
GetDateFormat(LOCALE_SYSTEM_DEFAULT, 0, NULL,
_T("yyyy-MM-dd"),
szDate, _countof(szDate));
GetTimeFormat (LOCALE_USER_DEFAULT, 0, NULL,
_T("hh:mm:ss tt"),
szTime, _countof(szTime));
查看'strftime',这两个最接近的POSIX等价物。 – user4815162342
我建议您查看[标准C++时间功能](http://en.cppreference.com/w/cpp/chrono),而不是继续使用特定于平台的功能。 –
*“...但不起作用”*不是有用的问题陈述。你需要说明它是如何工作的。您还应该显示产生错误的编译器命令。 – jww