// 获取系统的时区、系统语言、时间戳等信息
static bool GetOsExtraInfo(std::string& osTimeZone, std::string& osSysLanguage, std::string& osTimeStamp)
{
// 系统时区信息
TIME_ZONE_INFORMATION tmp;
::GetTimeZoneInformation(&tmp);
int tzRet = tmp.Bias / (-60);
osTimeZone = std::to_string(tzRet); // 示例: 东8区返回的是 8, 西8区返回的是 -8
// 系统语言信息
LCID localeId = ::GetUserDefaultLCID();
unsigned long lang = localeId;
osSysLanguage = std::to_string(lang);
// 系统时间戳信息(1970到当前的秒数)
std::chrono::system_clock::time_point nowTime = std::chrono::system_clock::now();
time_t tt;
tt = std::chrono::system_clock::to_time_t(nowTime);
long sec = tt;
osTimeStamp = std::to_string(sec);
return true;
}
// 时区、系统语言信息是采用的Windows api获取
// 系统时间戳采用的 C++11 chrono 时间库, 可跨平台使用.