SYSTEMTIME 转化为 tm struct 并根据本地的设置输出
来源:互联网 发布:网站群发软件 编辑:程序博客网 时间:2024/05/29 03:26
BOOL GetTimeInf(TCHAR *ptszTimeFormatCtrl, TCHAR *ptszTimeBuf, DWORD dwBufLen){// 0. variable definitionSYSTEMTIME Reg_systime; // System time from regist_locale_t locale = NULL; // local to determine time show stylestruct tm Reg_showtime; // Reg show time from System time// 1. Init Reg_systimeZeroMemory(&Reg_systime, 0, sizeof(SYSTEMTIME));DWORD dwTimeLen = sizeof(SYSTEMTIME);// 2. Read system time from regGetSystemTime(&Reg_systime);// 3. Get Reg_showtime from Reg_systime// month and year need to modify, others are the sameReg_showtime.tm_sec = Reg_systime.wSecond; // SecondReg_showtime.tm_min = Reg_systime.wMinute; // MinuteReg_showtime.tm_hour = Reg_systime.wHour; // HourReg_showtime.tm_mday = Reg_systime.wDay; // DayReg_showtime.tm_mon = Reg_systime.wMonth -1; // MonthReg_showtime.tm_year = Reg_systime.wYear - 1900; // YearReg_showtime.tm_wday = Reg_systime.wDayOfWeek; // Day of week// 4. Get the implementation-defined native environmentlocale = _create_locale(LC_ALL,"");if (locale == NULL){ OutputDebugString(TEXT("_create_locale() failed\r\n")); return FALSE;}// 5. Set ptszTimeBuf value_tcsftime_l(ptszTimeBuf, dwBufLen, ptszTimeFormatCtrl, &Reg_showtime, locale);if (locale){ _free_locale(locale);}return TURE;}
用法:
int _tmain(int argc, _TCHAR* argv[]){TCHAR *ptszTimeFormat = TEXT("%#c"); //TEXT("%c")TCHAR tszTimeBuf[100] = {0};BOOL bres = GetTimeFromInf(ptszTimeFormat, tszTimeBuf, 100);if (!bres){OutputDebugString(TEXT("GetTimeFromRegist failed !\r\n"));return 0;}TCHAR tszDebugMsg[100] ={0};_stprintf_s(tszDebugMsg, 100, TEXT("%s Format UTC Time is %s\r\n"), ptszTimeFormat, tszTimeBuf);MessageBox(NULL, tszDebugMsg, TEXT("test"), MB_OK);}
0 0
- SYSTEMTIME 转化为 tm struct 并根据本地的设置输出
- 将当前时间戳转化为 struct tm 结构 然后获取自己想要的数据
- SYSTEMTIME、 time_t、tm 的相互转换
- struct tm 的应用
- struct tm 的应用
- struct tm 的介绍
- struct tm 赋值设置时间
- FILETIME SYSTEMTIME tm time_t
- tm ,time_t,SYSTEMTIME转换
- FILETIME SYSTEMTIME tm time_t
- 将字符串转化为tm结构体的数据
- time_t tm systemtime 互相转换
- time_t tm systemtime 互相转换
- time_t tm systemtime 互相转换
- time_t tm systemtime 互相转换
- NSDate存储的是世界标准时(UTC),输出时需要根据时区转换为本地时间
- NSDate存储的是世界标准时(UTC),输出时需要根据时区转换为本地时间
- struct tm
- java获取当前时间
- 获取SDCard文件读取权限问题
- Linux netfilter/iptables内核模块介绍
- 获取屏幕的宽高等等
- 【无中生有】---6---系统日志记录系统存储设计
- SYSTEMTIME 转化为 tm struct 并根据本地的设置输出
- 第6周项目3
- DB2 备份恢复
- struts配置 package 继承json-default 出错
- js设置div竖直滚动条处于最底部
- Some Deprecated Methods & Solutions
- winfrom自动升级
- java容器(一)
- 窗口背景刷新太慢问题的解决方案