这篇教程C++ GetTimeZoneInformation函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中GetTimeZoneInformation函数的典型用法代码示例。如果您正苦于以下问题:C++ GetTimeZoneInformation函数的具体用法?C++ GetTimeZoneInformation怎么用?C++ GetTimeZoneInformation使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了GetTimeZoneInformation函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: UpdateDatavoid Timer_Calibrate::OnBnClickedOk(){ // TODO: 在此添加控件通知处理程序代码 //OnOK(); KILLTIMER; had_select=false; UpdateData(true); unsigned char t_time[8]= {0}; unsigned short temp_us=0; temp_us=m_date_time.GetYear(); t_time[0]=temp_us/100; t_time[1]=temp_us%100; t_time[2]=m_date_time.GetMonth(); t_time[3]=m_date_time.GetDayOfWeek();// if(t_time[3]==1)// t_time[3]=6;// else// t_time[3]-=2; if(t_time[3]==1) t_time[3]=7; else t_time[3]-=1; t_time[4]=m_date_time.GetDay(); t_time[5]=m_time_time.GetHour(); t_time[6]=m_time_time.GetMinute(); t_time[7]=m_time_time.GetSecond(); Write_Multi(g_tstat_id,t_time,200,8); int t=_wtoi(m_time_zone.Right(m_time_zone.GetLength()-1)); if(m_time_zone.Left(1)=="+") t+=12; else t=12-t; write_one(g_tstat_id,11,t); Read_Multi(g_tstat_id,machine_time,200,8,3); if(machine_time[1]<10) m_machine_time.Format(_T(" %d/%d/%d0%d %d:%d:%d"),machine_time[2],machine_time[4],machine_time[0],machine_time[1],machine_time[5],machine_time[6],machine_time[7]); else m_machine_time.Format(_T(" %d/%d/%d%d %d:%d:%d"),machine_time[2],machine_time[4],machine_time[0],machine_time[1],machine_time[5],machine_time[6],machine_time[7]); if(machine_time[5]>12) m_machine_time+=_T(" PM"); else m_machine_time+=_T(" AM"); m_NCDateCtrl.SetDate(machine_time[0]*100+machine_time[1],machine_time[2],machine_time[4]); m_NCTimeCtrl.SetTime(machine_time[5],machine_time[6],machine_time[7]); if(had_select==false) m_time_time=m_time_time.GetCurrentTime(); TIME_ZONE_INFORMATION temp; GetTimeZoneInformation(&temp); m_time_zone_str=temp.StandardName; int i_temp=read_one(g_tstat_id,11); if(temp.Bias>0) { m_time_zone=_T("-"); CString t; t.Format(_T("%d"),temp.Bias/60); m_time_zone=m_time_zone+t; if(i_temp==255) { m_building_time_zone.SetCurSel(12-temp.Bias/60); write_one(g_tstat_id,11,(short)(12-temp.Bias/60)); } else if(i_temp>=0) m_building_time_zone.SetCurSel(i_temp); } else { m_time_zone=_T("+"); CString t; t.Format(_T("%d"),temp.Bias/-60); m_time_zone=m_time_zone+t; if(i_temp==255) { m_building_time_zone.SetCurSel(12-temp.Bias/60); write_one(g_tstat_id,11,(short)(12-temp.Bias/60)); } else if(i_temp>=0) m_building_time_zone.SetCurSel(i_temp); } UpdateData(FALSE); SETTIMER;}
开发者ID:mtalaat,项目名称:T3000_Building_Automation_System,代码行数:86,
示例2: __gnat_localtime_tzoffvoid__gnat_localtime_tzoff (const time_t *timer, const int *is_historic, long *off){ TIME_ZONE_INFORMATION tzi; BOOL rtx_active; DWORD tzi_status;#ifdef RTX rtx_active = 1;#else rtx_active = 0;#endif (*Lock_Task) (); tzi_status = GetTimeZoneInformation (&tzi); /* Processing for RTX targets or cases where we simply want to extract the offset of the current time zone, regardless of the date. */ if (rtx_active || !is_historic) { *off = tzi.Bias; /* The system is operating in the range covered by the StandardDate member. */ if (tzi_status == TIME_ZONE_ID_STANDARD) { *off = *off + tzi.StandardBias; } /* The system is operating in the range covered by the DaylightDate member. */ else if (tzi_status == TIME_ZONE_ID_DAYLIGHT) { *off = *off + tzi.DaylightBias; } *off = *off * -60; } /* Time zone offset calculations for a historic or future date */ else { union { FILETIME ft_time; unsigned long long ull_time; } utc_time, local_time; SYSTEMTIME utc_sys_time, local_sys_time; BOOL status; /* First convert unix time_t structure to windows FILETIME format. */ utc_time.ull_time = ((unsigned long long) *timer + w32_epoch_offset) * 10000000ULL; /* If GetTimeZoneInformation does not return a value between 0 and 2 then it means that we were not able to retrieve timezone informations. Note that we cannot use here FileTimeToLocalFileTime as Windows will use in always in this case the current timezone setting. As suggested on MSDN we use the following three system calls to get the right information. Note also that starting with Windows Vista new functions are provided to get timezone settings that depend on the year. We cannot use them as we still support Windows XP and Windows 2003. */ status = (tzi_status >= 0 && tzi_status <= 2) && FileTimeToSystemTime (&utc_time.ft_time, &utc_sys_time) && SystemTimeToTzSpecificLocalTime (&tzi, &utc_sys_time, &local_sys_time) && SystemTimeToFileTime (&local_sys_time, &local_time.ft_time); /* An error has occured, return invalid_tzoff */ if (!status) { *off = __gnat_invalid_tzoff; } else { if (local_time.ull_time > utc_time.ull_time) { *off = (long) ((local_time.ull_time - utc_time.ull_time) / 10000000ULL); } else { *off = - (long) ((utc_time.ull_time - local_time.ull_time) / 10000000ULL); } } } (*Unlock_Task) ();}
开发者ID:BreakawayConsulting,项目名称:gcc,代码行数:88,
|