gpt4 book ai didi

c++ - Linux:GetDateFormat() 和 GetTimeFormat() 是否存在 C++?

转载 作者:太空宇宙 更新时间:2023-11-04 09:16:48 29 4
gpt4 key购买 nike

我导入了下面的库。

#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() 来自 <ctime> ,这不一样,但与您提到的这些 MSDN 功能非常匹配。

但是,我强烈建议您检查一下 C++ 提供的内容:

<chrono>

这是标准 C++ 库的一部分,因此您不必担心特定于平台的实现(Windows、Linux 等)。

关于c++ - Linux:GetDateFormat() 和 GetTimeFormat() 是否存在 C++?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46640707/

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