本文整理汇总了C++中GetTimeZoneInformation函数的典型用法代码示例。如果您正苦于以下问题:C++ GetTimeZoneInformation函数的具体用法?C++ GetTimeZoneInformation怎么用?C++ GetTimeZoneInformation使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetTimeZoneInformation函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: UpdateData
void 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,代码来源:Timer_Calibrate.cpp
示例2: __gnat_localtime_tzoff
void
__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,代码来源:sysdep.c
示例3: GetDaylightFlag
/*********************************************************************
* GetDaylightFlag ([email protected])
*
* Specifies if daylight savings time is in operation.
*
* NOTES
* This function is called from the Win98's control applet timedate.cpl.
*
* RETURNS
* TRUE if daylight savings time is in operation.
* FALSE otherwise.
*/
BOOL WINAPI GetDaylightFlag(void)
{
TIME_ZONE_INFORMATION tzinfo;
return GetTimeZoneInformation( &tzinfo) == TIME_ZONE_ID_DAYLIGHT;
}
开发者ID:AlexSteel,项目名称:wine,代码行数:17,代码来源:time.c
示例4: ASSERT
// **************************************************************************
// GetValue ()
//
// Description:
// Return a string representing the value of a variant.
//
// Parameters:
// VARIANT &vtVal Input variant.
// TCHAR *pBuffer Pointer to buffer for output string.
// int nBufLen Size of output buffer.
//
// Returns:
// void
// **************************************************************************
void CKItemPropertiesDlg::GetValue (VARIANT &vtVal, // [in]
TCHAR *pBuffer, // [out]
int nBufLen) // [in]
{
ASSERT (pBuffer != NULL);
ASSERT (nBufLen > 0);
// Declare a CString to help construct result string:
CString strVal;
// Format string according to data type:
switch (vtVal.vt)
{
case VT_BOOL:
strVal.Format (_T("%d"), vtVal.boolVal);
break;
case VT_UI1:
strVal.Format (_T("%u"), vtVal.bVal);
break;
case VT_I1:
strVal.Format (_T("%d"), vtVal.cVal);
break;
case VT_UI2:
strVal.Format (_T("%u"), vtVal.uiVal);
break;
case VT_I2:
strVal.Format (_T("%d"), vtVal.iVal);
break;
case VT_UI4:
strVal.Format (_T("%u"), vtVal.ulVal);
break;
case VT_I4:
strVal.Format (_T("%d"), vtVal.lVal);
break;
case VT_R4:
strVal.Format (_T("%G"), vtVal.fltVal);
break;
case VT_R8:
strVal.Format (_T("%G"), vtVal.dblVal);
break;
case VT_BSTR:
strVal = vtVal.bstrVal;
break;
case VT_DATE:
{
bool bSuccess = false;
// Cariant time to system time (UTC):
SYSTEMTIME systime;
if (VariantTimeToSystemTime (vtVal.dblVal, &systime))
{
// Get time zone information:
TIME_ZONE_INFORMATION tTZI;
if (GetTimeZoneInformation (&tTZI) != TIME_ZONE_ID_INVALID)
{
// Localize system time:
SYSTEMTIME systimelocal;
if (SystemTimeToTzSpecificLocalTime (&tTZI, &systime, &systimelocal))
{
strVal.Format (_T("%02d:%02d:%02d"),
systimelocal.wHour, systimelocal.wMinute, systimelocal.wSecond);
bSuccess = true;
}
}
}
if (!bSuccess)
strVal = _T("???");
}
break;
case VT_UI1 | VT_ARRAY:
case VT_I1 | VT_ARRAY:
case VT_UI2 | VT_ARRAY:
case VT_I2 | VT_ARRAY:
//.........这里部分代码省略.........
开发者ID:wfmdyh,项目名称:wecan,代码行数:101,代码来源:itempropertiesdlg.cpp
示例5: GetLocalTime
/*
** Read the options specified in the ini file.
**
*/
void CMeasureTime::ReadOptions(CConfigParser& parser, const WCHAR* section)
{
CMeasure::ReadOptions(parser, section);
m_Format = parser.ReadString(section, L"Format", L"");
m_TimeStamp = parser.ReadFloat(section, L"TimeStamp", -1);
if (m_TimeStamp < 0.0)
{
const WCHAR* timezone = parser.ReadString(section, L"TimeZone", L"local").c_str();
if (_wcsicmp(L"local", timezone) == 0)
{
SYSTEMTIME sysLocalTime, sysUTCTime;
GetLocalTime(&sysLocalTime);
GetSystemTime(&sysUTCTime);
FILETIME ftLocalTime, ftUTCTime;
SystemTimeToFileTime(&sysLocalTime, &ftLocalTime);
SystemTimeToFileTime(&sysUTCTime, &ftUTCTime);
LARGE_INTEGER largeInt1, largeInt2;
largeInt1.HighPart = ftLocalTime.dwHighDateTime;
largeInt1.LowPart = ftLocalTime.dwLowDateTime;
largeInt2.HighPart = ftUTCTime.dwHighDateTime;
largeInt2.LowPart = ftUTCTime.dwLowDateTime;
m_DeltaTime.QuadPart = largeInt1.QuadPart - largeInt2.QuadPart;
}
else
{
double zone = parser.ParseDouble(timezone, 0.0);
bool dst = 1 == parser.ReadInt(section, L"DaylightSavingTime", 1);
struct tm* today;
time_t now;
time(&now);
today = localtime(&now);
if (dst && today->tm_isdst)
{
// Add DST
TIME_ZONE_INFORMATION tzi;
GetTimeZoneInformation(&tzi);
m_DeltaTime.QuadPart = (LONGLONG)((zone * 3600) - tzi.DaylightBias * 60) * 10000000;
}
else
{
m_DeltaTime.QuadPart = (LONGLONG)(zone * 3600) * 10000000;
}
}
}
else
{
m_DeltaTime.QuadPart = 0;
}
if (!m_Initialized)
{
// Initialize m_Time to avoid causing EINVAL in TimeToString() until calling UpdateValue()
FillCurrentTime();
}
}
开发者ID:AlfiyaZi,项目名称:rainmeter,代码行数:68,代码来源:MeasureTime.cpp
示例6: APR_DECLARE
APR_DECLARE(apr_status_t) apr_time_exp_lt(apr_time_exp_t *result,
apr_time_t input)
{
SYSTEMTIME st;
FILETIME ft, localft;
AprTimeToFileTime(&ft, input);
#if APR_HAS_UNICODE_FS && !defined(_WIN32_WCE)
IF_WIN_OS_IS_UNICODE
{
TIME_ZONE_INFORMATION *tz;
SYSTEMTIME localst;
apr_time_t localtime;
get_local_timezone(&tz);
FileTimeToSystemTime(&ft, &st);
/* The Platform SDK documents that SYSTEMTIME/FILETIME are
* generally UTC. We use SystemTimeToTzSpecificLocalTime
* because FileTimeToLocalFileFime is documented that the
* resulting time local file time would have DST relative
* to the *present* date, not the date converted.
*/
SystemTimeToTzSpecificLocalTime(tz, &st, &localst);
SystemTimeToAprExpTime(result, &localst);
result->tm_usec = (apr_int32_t) (input % APR_USEC_PER_SEC);
/* Recover the resulting time as an apr time and use the
* delta for gmtoff in seconds (and ignore msec rounding)
*/
SystemTimeToFileTime(&localst, &localft);
FileTimeToAprTime(&localtime, &localft);
result->tm_gmtoff = (int)apr_time_sec(localtime)
- (int)apr_time_sec(input);
/* To compute the dst flag, we compare the expected
* local (standard) timezone bias to the delta.
* [Note, in war time or double daylight time the
* resulting tm_isdst is, desireably, 2 hours]
*/
result->tm_isdst = (result->tm_gmtoff / 3600)
- (-(tz->Bias + tz->StandardBias) / 60);
}
#endif
#if APR_HAS_ANSI_FS || defined(_WIN32_WCE)
ELSE_WIN_OS_IS_ANSI
{
TIME_ZONE_INFORMATION tz;
/* XXX: This code is simply *wrong*. The time converted will always
* map to the *now current* status of daylight savings time.
*/
FileTimeToLocalFileTime(&ft, &localft);
FileTimeToSystemTime(&localft, &st);
SystemTimeToAprExpTime(result, &st);
result->tm_usec = (apr_int32_t) (input % APR_USEC_PER_SEC);
switch (GetTimeZoneInformation(&tz)) {
case TIME_ZONE_ID_UNKNOWN:
result->tm_isdst = 0;
/* Bias = UTC - local time in minutes
* tm_gmtoff is seconds east of UTC
*/
result->tm_gmtoff = tz.Bias * -60;
break;
case TIME_ZONE_ID_STANDARD:
result->tm_isdst = 0;
result->tm_gmtoff = (tz.Bias + tz.StandardBias) * -60;
break;
case TIME_ZONE_ID_DAYLIGHT:
result->tm_isdst = 1;
result->tm_gmtoff = (tz.Bias + tz.DaylightBias) * -60;
break;
default:
/* noop */;
}
}
#endif
return APR_SUCCESS;
}
开发者ID:ohmann,项目名称:checkapi,代码行数:84,代码来源:time.c
示例7: test_mktime
static void test_mktime(void)
{
TIME_ZONE_INFORMATION tzinfo;
DWORD res = GetTimeZoneInformation(&tzinfo);
struct tm my_tm, sav_tm;
time_t nulltime, local_time;
char TZ_env[256];
char buffer[64];
int year;
time_t ref, secs;
year = get_test_year( &ref );
ref += SECSPERDAY;
ok (res != TIME_ZONE_ID_INVALID, "GetTimeZoneInformation failed\n");
WideCharToMultiByte( CP_ACP, 0, tzinfo.StandardName, -1, buffer, sizeof(buffer), NULL, NULL );
trace( "bias %d std %d dst %d zone %s\n",
tzinfo.Bias, tzinfo.StandardBias, tzinfo.DaylightBias, buffer );
/* Bias may be positive or negative, to use offset of one day */
my_tm = *localtime(&ref); /* retrieve current dst flag */
secs = SECSPERDAY - tzinfo.Bias * SECSPERMIN;
secs -= (my_tm.tm_isdst ? tzinfo.DaylightBias : tzinfo.StandardBias) * SECSPERMIN;
my_tm.tm_mday = 1 + secs/SECSPERDAY;
secs = secs % SECSPERDAY;
my_tm.tm_hour = secs / SECSPERHOUR;
secs = secs % SECSPERHOUR;
my_tm.tm_min = secs / SECSPERMIN;
secs = secs % SECSPERMIN;
my_tm.tm_sec = secs;
my_tm.tm_year = year;
my_tm.tm_mon = 0;
sav_tm = my_tm;
local_time = mktime(&my_tm);
ok(local_time == ref, "mktime returned %u, expected %u\n",
(DWORD)local_time, (DWORD)ref);
/* now test some unnormalized struct tm's */
my_tm = sav_tm;
my_tm.tm_sec += 60;
my_tm.tm_min -= 1;
local_time = mktime(&my_tm);
ok(local_time == ref, "Unnormalized mktime returned %u, expected %u\n",
(DWORD)local_time, (DWORD)ref);
ok( my_tm.tm_year == sav_tm.tm_year && my_tm.tm_mon == sav_tm.tm_mon &&
my_tm.tm_mday == sav_tm.tm_mday && my_tm.tm_hour == sav_tm.tm_hour &&
my_tm.tm_sec == sav_tm.tm_sec,
"mktime returned %2d-%02d-%02d %02d:%02d expected %2d-%02d-%02d %02d:%02d\n",
my_tm.tm_year,my_tm.tm_mon,my_tm.tm_mday,
my_tm.tm_hour,my_tm.tm_sec,
sav_tm.tm_year,sav_tm.tm_mon,sav_tm.tm_mday,
sav_tm.tm_hour,sav_tm.tm_sec);
my_tm = sav_tm;
my_tm.tm_min -= 60;
my_tm.tm_hour += 1;
local_time = mktime(&my_tm);
ok(local_time == ref, "Unnormalized mktime returned %u, expected %u\n",
(DWORD)local_time, (DWORD)ref);
ok( my_tm.tm_year == sav_tm.tm_year && my_tm.tm_mon == sav_tm.tm_mon &&
my_tm.tm_mday == sav_tm.tm_mday && my_tm.tm_hour == sav_tm.tm_hour &&
my_tm.tm_sec == sav_tm.tm_sec,
"mktime returned %2d-%02d-%02d %02d:%02d expected %2d-%02d-%02d %02d:%02d\n",
my_tm.tm_year,my_tm.tm_mon,my_tm.tm_mday,
my_tm.tm_hour,my_tm.tm_sec,
sav_tm.tm_year,sav_tm.tm_mon,sav_tm.tm_mday,
sav_tm.tm_hour,sav_tm.tm_sec);
my_tm = sav_tm;
my_tm.tm_mon -= 12;
my_tm.tm_year += 1;
local_time = mktime(&my_tm);
ok(local_time == ref, "Unnormalized mktime returned %u, expected %u\n",
(DWORD)local_time, (DWORD)ref);
ok( my_tm.tm_year == sav_tm.tm_year && my_tm.tm_mon == sav_tm.tm_mon &&
my_tm.tm_mday == sav_tm.tm_mday && my_tm.tm_hour == sav_tm.tm_hour &&
my_tm.tm_sec == sav_tm.tm_sec,
"mktime returned %2d-%02d-%02d %02d:%02d expected %2d-%02d-%02d %02d:%02d\n",
my_tm.tm_year,my_tm.tm_mon,my_tm.tm_mday,
my_tm.tm_hour,my_tm.tm_sec,
sav_tm.tm_year,sav_tm.tm_mon,sav_tm.tm_mday,
sav_tm.tm_hour,sav_tm.tm_sec);
my_tm = sav_tm;
my_tm.tm_mon += 12;
my_tm.tm_year -= 1;
local_time = mktime(&my_tm);
ok(local_time == ref, "Unnormalized mktime returned %u, expected %u\n",
(DWORD)local_time, (DWORD)ref);
ok( my_tm.tm_year == sav_tm.tm_year && my_tm.tm_mon == sav_tm.tm_mon &&
my_tm.tm_mday == sav_tm.tm_mday && my_tm.tm_hour == sav_tm.tm_hour &&
my_tm.tm_sec == sav_tm.tm_sec,
"mktime returned %2d-%02d-%02d %02d:%02d expected %2d-%02d-%02d %02d:%02d\n",
my_tm.tm_year,my_tm.tm_mon,my_tm.tm_mday,
my_tm.tm_hour,my_tm.tm_sec,
sav_tm.tm_year,sav_tm.tm_mon,sav_tm.tm_mday,
sav_tm.tm_hour,sav_tm.tm_sec);
/* now a bad time example */
my_tm = sav_tm;
my_tm.tm_year = 69;
local_time = mktime(&my_tm);
ok((local_time == -1), "(bad time) mktime returned %d, expected -1\n", (int)local_time);
//.........这里部分代码省略.........
开发者ID:Barrell,项目名称:wine,代码行数:101,代码来源:time.c
示例8: _T
//.........这里部分代码省略.........
sStatusMsg = _T("Unexpected status code");
m_scn->SetProgress(sStatusMsg, 0);
goto exit;
}
}
sStatusMsg.Format(_T("Start sending email data"));
m_scn->SetProgress(sStatusMsg, 1);
// Send DATA
res=SendMsg(sock, _T("DATA\r\n"), response, RESPONSE_BUFF_SIZE);
if (res!=354)
{
sStatusMsg = _T("Unexpected status code");
m_scn->SetProgress(sStatusMsg, 0);
goto exit;
}
// Get current time
time_t cur_time;
time(&cur_time);
char szDateTime[64] = "";
#if _MSC_VER >= 1400
struct tm ltimeinfo;
localtime_s(<imeinfo, &cur_time );
strftime(szDateTime, 64, "%a, %d %b %Y %H:%M:%S", <imeinfo);
#else
struct tm* ltimeinfo = localtime(&cur_time );
strftime(szDateTime, 64, "%a, %d %b %Y %H:%M:%S", ltimeinfo);
#endif
TIME_ZONE_INFORMATION tzi;
GetTimeZoneInformation(&tzi);
int diff_hours = -tzi.Bias/60;
int diff_mins = abs(tzi.Bias%60);
// Send date header
str.Format(_T("Date: %s %c%02d%02d\r\n"), strconv.a2t(szDateTime), diff_hours>=0?'+':'-', diff_hours, diff_mins);
sMsg = str;
// Send From header
str.Format(_T("From: <%s>\r\n"), msg->GetSenderAddress());
sMsg += str;
sMsg += sBodyTo;
// Send subject
str.Format(_T("Subject: %s\r\n"), msg->GetSubject());
sMsg += str;
// Send MIME-Version header
sMsg += "MIME-Version: 1.0\r\n";
// Send Content-Type
sMsg += "Content-Type: multipart/mixed; boundary=KkK170891tpbkKk__FV_KKKkkkjjwq\r\n";
sMsg += "\r\n\r\n";
res = SendMsg(sock, sMsg);
if(res!=sMsg.GetLength())
goto exit;
/* Message text */
sStatusMsg.Format(_T("Sending message text"));
m_scn->SetProgress(sStatusMsg, 15);
sMsg = "--KkK170891tpbkKk__FV_KKKkkkjjwq\r\n";
sMsg += "Content-Type: text/plain; charset=UTF-8\r\n";
sMsg += "\r\n";
sMsg += sUTF8Text.c_str();
sMsg += "\r\n";
开发者ID:McSimp,项目名称:Borderlands2SDK,代码行数:67,代码来源:smtpclient.cpp
示例9: main
int __cdecl main(int argc, char **argv)
{
time_t LTime;
char *DateResult;
TIME_ZONE_INFORMATION tzInformation;
/*
* Initialize the PAL and return FAILURE if this fails
*/
if (PAL_Initialize(argc, argv))
{
return FAIL;
}
// Get the current timezone information
GetTimeZoneInformation(&tzInformation);
/*
* Test #1
*/
/* set the valid date in time_t format, adjusted for current time zone*/
LTime = VAL_SUN_JAN_17_2038 + (tzInformation.Bias * 60);
/* convert it to string using ctime*/
DateResult = ctime( <ime );
/* if it's null, ctime failed*/
if (DateResult == NULL)
{
Fail ("ERROR: (Test #1) ctime returned NULL. Expected string\n");
}
/* test if the entire string can ba access normaly */
if(IsBadReadPtr(DateResult, STR_TIME_SIZE)==0)
{
/* compare result with win2000 result */
if(strcmp( DateResult, STR_SUN_JAN_17_2038)!=0)
{
Fail("ERROR: (Test #1) ctime returned an unexpected string "
"%s, expexted string is %s\n"
,DateResult, STR_SUN_JAN_17_2038);
}
}
else
{
Fail ("ERROR: (Test #1) ctime returned a bad pointer.\n");
}
/*
* Test #2
*/
/* Set the valid date in time_t format, adjusted for current time zone */
LTime = VAL_FRI_JAN_02_1970 + (tzInformation.Bias * 60);
/* convert it to string using ctime */
DateResult = ctime( <ime );
/* if it's null, ctime failed*/
if (DateResult == NULL)
{
Fail ("ERROR: (Test #2) ctime returned NULL. Expected string\n");
}
/* test if the entire string can ba access normaly */
if(IsBadReadPtr(DateResult, STR_TIME_SIZE)==0)
{
/* compare result with win2000 result */
if (strcmp(DateResult, STR_FRI_JAN_02_1970) != 0
&& strcmp(DateResult, STR_FRI_JAN__2_1970) != 0)
{
Fail("ERROR: (Test #2) ctime returned an unexpected string "
"%s, expected string is %s\n"
,DateResult, STR_FRI_JAN_02_1970);
}
}
else
{
Fail ("ERROR: (Test #2) ctime returned a bad pointer.\n");
}
/*
* Test #3
*/
/* specify an invalid time */
LTime = -1;
/* try to convert it */
DateResult = ctime( <ime );
/* Check the result for errors, should fail in this case */
if (DateResult != NULL)
{
Fail ("ERROR: (Test #3) ctime returned something different from NULL.:"
//.........这里部分代码省略.........
开发者ID:Afshintm,项目名称:coreclr,代码行数:101,代码来源:test1.c
示例10: GetTimeZoneInformation
int Timezone::dst()
{
TIME_ZONE_INFORMATION tzInfo;
DWORD dstFlag = GetTimeZoneInformation(&tzInfo);
return dstFlag == TIME_ZONE_ID_DAYLIGHT ? -tzInfo.DaylightBias*60 : 0;
}
开发者ID:carvalhomb,项目名称:tsmells,代码行数:6,代码来源:Timezone_WIN32.cpp
示例11: main
int __cdecl main(int argc, char **argv)
{
FILETIME UTCTime, LocalTime;
ULONG64 FullFileTime, FullLocalTime, CorrectTime;
TIME_ZONE_INFORMATION ZoneInfo;
int DeltaBetweenLocalAndUTC;
int result;
if (0 != PAL_Initialize(argc,argv))
{
return FAIL;
}
/* This is a valid UTC file time generated with GetFileTime */
UTCTime.dwLowDateTime = 1867954880;
UTCTime.dwHighDateTime = 29437095;
/* Call the function */
result = FileTimeToLocalFileTime(&UTCTime,&LocalTime);
if(result == 0)
{
Fail("ERROR: FileTimeToLocalTime has returned zero, which "
"indicates that it failed.");
}
/* We need to get the time zone that the user is running in. */
result = GetTimeZoneInformation(&ZoneInfo);
/* Use the Time Zone Information to construct the delta between UTC
and local time -- in hours.
*/
if(result == TIME_ZONE_ID_STANDARD)
{
DeltaBetweenLocalAndUTC =
(ZoneInfo.Bias + ZoneInfo.StandardBias);
}
else if (result == TIME_ZONE_ID_DAYLIGHT)
{
DeltaBetweenLocalAndUTC =
(ZoneInfo.Bias + ZoneInfo.DaylightBias);
}
else
{
DeltaBetweenLocalAndUTC = (ZoneInfo.Bias);
}
/* Change the UTC and Local FILETIME structures into ULONG64
types
*/
FullFileTime = ((((ULONG64)UTCTime.dwHighDateTime)<<32) |
((ULONG64)UTCTime.dwLowDateTime));
FullLocalTime = ((((ULONG64)LocalTime.dwHighDateTime)<<32) |
((ULONG64)LocalTime.dwLowDateTime));
/* This magic number is 10000000 * 60 * 60 -- which is the
number of 100s of Nanseconds in a second, multiplied by the number
of seconds in a minute, multiplied by the number of minutes in an
hour.
The correct time is the delta in hundreds of nanoseconds between
Local and UTC times.
*/
CorrectTime = 600000000 * ((ULONG64)DeltaBetweenLocalAndUTC);
/* Now check to ensure that the difference between the Local and UTC
times that was calculated with the function equals what it should be.
*/
if((FullFileTime - FullLocalTime) != CorrectTime)
{
Fail("ERROR: The LocalFileTime that was returned is not equal to "
"what the LocalFileTime should have been.");
}
PAL_Terminate();
return PASS;
}
开发者ID:smartmaster,项目名称:sscli,代码行数:82,代码来源:filetimetolocalfiletime.c
示例12: switch
BOOL CALLBACK CDateTime::DateTimeProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
static HWND hwndTimeZone;
static HKEY g_hKey = NULL;
static CDlgAnchor g_dlgAnchor;
switch (message)
{
case WM_SIZE :
{
g_dlgAnchor.OnSize();
}
break;
case WM_INITDIALOG:
{
g_dlgAnchor.Init(hwndDlg);
g_dlgAnchor.Add(IDC_COMBO_TIMEZONE, ANCHOR_ALL &~ ANCHOR_BOTTOM);
hwndTimeZone = GetDlgItem(hwndDlg, IDC_COMBO_TIMEZONE);
TIME_ZONE_INFORMATION info = {0};
GetTimeZoneInformation(&info);
int index = ComboBox_AddString(hwndTimeZone, info.StandardName);
index = ComboBox_SetItemData(hwndTimeZone, index, info.StandardBias);
g_hKey = (HKEY)lParam;
DWORD dwOffset = 0;
RegistryGetDWORD(g_hKey, NULL, REG_TimeOffset, &dwOffset);
ComboBox_SetCurSel(hwndTimeZone, 0);
SHINITDLGINFO shidi;
// Create a Done button and size it.
shidi.dwMask = SHIDIM_FLAGS;
shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN | SHIDIF_SIZEDLGFULLSCREEN;
shidi.hDlg = hwndDlg;
SHInitDialog(&shidi);
SHMENUBARINFO mbi;
memset(&mbi, 0, sizeof(SHMENUBARINFO));
mbi.cbSize = sizeof(SHMENUBARINFO);
mbi.hwndParent = hwndDlg;
mbi.nToolBarId = IDR_Flipper_SET_MENUBAR;
mbi.hInstRes = CDateTime::g_hInstance;
mbi.nBmpId = 0;
mbi.cBmpImages = 0;
SHCreateMenuBar(&mbi);
SetFocus(hwndTimeZone);
return 0;
}
break;
case WM_COMMAND:
{
switch (LOWORD(wParam))
{
case IDM_Flipper_SET_ACCEPT :
case IDOK:
{
WCHAR wzName[MAX_PATH];
DWORD dwName = ARRAYSIZE(wzName);
int index = ComboBox_GetCurSel(hwndTimeZone);
DWORD dwTimeZone = ComboBox_GetItemData(hwndTimeZone, index);
RegistrySetDWORD(g_hKey, NULL, REG_TimeOffset, dwTimeZone);
EndDialog(hwndDlg, IDOK);
}
break;
case IDM_Flipper_SET_CANCEL:
{
EndDialog(hwndDlg, IDOK);
}
break;
}
}
break;
case WM_DESTROY:
{
Sleep(0);
}
break;
}
return FALSE;
}
开发者ID:nbclark,项目名称:flipper,代码行数:89,代码来源:DateTime.cpp
示例13: GetDlgItem
BOOL Timer_Calibrate::OnInitDialog()
{
CDialog::OnInitDialog();
m_DatetimeEdit.ShowWindow(SW_HIDE);
GetDlgItem(IDC_STATIC101)->ShowWindow(SW_HIDE);
// TODO: 在此添加额外的初始化
had_select=false;
SETTIMER;
//SetTimer(1,30000,NULL);
CString strtemp;
for(int i=-12; i<=13; i++)
{
if(i>=0)
strtemp.Format(_T("(GMT+%d)"),i);
else
strtemp.Format(_T("(GMT%d)"),i);
m_building_time_zone.AddString(strtemp);
}
UpdateData(true);
Read_Multi(g_tstat_id,machine_time,200,8,3);
//unsigned char local_time[8];
// memcpy(&local_time[0], &multi_register_value[200],8);
// memcpy(&machine_time[0], &multi_register_value[200],8*sizeof(unsigned short));
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;
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
开发者ID:mtalaat,项目名称:T3000_Building_Automation_System,代码行数:80,代码来源:Timer_Calibrate.cpp
示例14: LocalTimeZone
dng_time_zone LocalTimeZone (const dng_date_time &dt)
{
dng_time_zone result;
if (dt.IsValid ())
{
#if qMacOS
CFTimeZoneRef zoneRef = CFTimeZoneCopyDefault ();
if (zoneRef)
{
CFGregorianDate gregDate;
gregDate.year = dt.fYear;
gregDate.month = dt.fMonth;
gregDate.day = dt.fDay;
gregDate.hour = dt.fHour;
gregDate.minute = dt.fMinute;
gregDate.second = dt.fSecond;
CFAbsoluteTime absTime = CFGregorianDateGetAbsoluteTime (gregDate, zoneRef);
CFTimeInterval secondsDelta = CFTimeZoneGetSecondsFromGMT (zoneRef, absTime);
CFRelease (zoneRef);
result.SetOffsetSeconds (secondsDelta);
if (result.IsValid ())
{
return result;
}
}
#endif
#if qWinOS
if (GetTimeZoneInformation != NULL &&
SystemTimeToTzSpecificLocalTime != NULL &&
SystemTimeToFileTime != NULL)
{
TIME_ZONE_INFORMATION tzInfo;
DWORD x = GetTimeZoneInformation (&tzInfo);
SYSTEMTIME localST;
memset (&localST, 0, sizeof (localST));
localST.wYear = (WORD) dt.fYear;
localST.wMonth = (WORD) dt.fMonth;
localST.wDay = (WORD) dt.fDay;
localST.wHour = (WORD) dt.fHour;
localST.wMinute = (WORD) dt.fMinute;
localST.wSecond = (WORD) dt.fSecond;
SYSTEMTIME utcST;
if (TzSpecificLocalTimeToSystemTime (&tzInfo, &localST, &utcST))
{
FILETIME localFT;
FILETIME utcFT;
(void) SystemTimeToFileTime (&localST, &localFT);
(void) SystemTimeToFileTime (&utcST , &utcFT );
uint64 time1 = (((uint64) localFT.dwHighDateTime) << 32) + localFT.dwLowDateTime;
uint64 time2 = (((uint64) utcFT .dwHighDateTime) << 32) + utcFT .dwLowDateTime;
// FILETIMEs are in units to 100 ns. Convert to seconds.
int64 time1Sec = time1 / 10000000;
int64 time2Sec = time2 / 10000000;
int32 delta = (int32) (time1Sec - time2Sec);
result.SetOffsetSeconds (delta);
if (result.IsValid ())
{
return result;
}
}
}
#endif
}
// Figure out local time zone.
//.........这里部分代码省略.........
开发者ID:Match-Yang,项目名称:digikam,代码行数:101,代码来源:dng_date_time.cpp
示例15: strftime
//.........这里部分代码省略.........
case 'B' : /* full month name */
GetDateFormatW(LOCALE_SYSTEM_DEFAULT, (DWORD)0, syst, L"MMMM", wout, BUFSIZ);
outp += WideCharToMultiByte(CP_ACP, (DWORD)NULL, wout, -1, out, BUFSIZ, NULL, NULL) -1;
break;
case 'c' : /* date and time representation appropriate for locale */
GetDateFormatW(LOCALE_SYSTEM_DEFAULT, DATE_LONGDATE, syst, NULL, wout, BUFSIZ);
outp += WideCharToMultiByte(CP_ACP, (DWORD)NULL, wout, -1, out, BUFSIZ, NULL, NULL) -1;
break;
case 'd' : /* day of month as decimal number 01 - 31 */
outp += sprintf(outp, "%02d", syst->wDay);
break;
case 'H' : /* hour in 24 hour format 00-23 */
outp += sprintf(outp, "%02d", syst->wHour);
break;
case 'I' : /* hour in 12 hour format 00-12 */
outp += sprintf(outp, "%02d", (syst->wHour > 12 ? syst->wHour - 12 : syst->wHour));
break;
case 'j' : /* day of year as decimal number 001 - 366 */
outp += sprintf(outp, "%03d", ptm->tm_yday +1);
break;
case 'm' : /* month as decimal number 01 - 12 */
outp += sprintf(outp, "%02d", syst->wMonth);
break;
case 'M' : /* minute as decimal number 00 - 59 */
outp += sprintf(outp, "%02d", syst->wMinute);
break;
case 'p' : /* current locale's AM/PM indicator for 12-hour clock */
GetTimeFormatW(LOCALE_SYSTEM_DEFAULT, (DWORD)0, syst, L"tt", wout, BUFSIZ);
outp += WideCharToMultiByte(CP_ACP, (DWORD)NULL, wout, -1, out, BUFSIZ, NULL, NULL) -1;
break;
case 'S' : /* second as decimal number 01 - 59 */
outp += sprintf(outp, "%02d", syst->wSecond);
break;
case 'U' : /* week of year as decimal number (Sunday is first day of week) 00 - 53 */
outp += sprintf(outp, "%02d", GetWeekNumber(ptm));
break;
case 'w' : /* weekday as decimal number (0 = Sunday) 0 - 6 */
outp += sprintf(outp, "%01d", ptm->tm_wday);
break;
case 'W' : /* week of year as decimal number (Monday is first day of week) 00 - 53 */
outp += sprintf(outp, "%02d", GetWeekNumber(ptm));
break;
case 'x' : /* date representation for current locale */
GetDateFormatW(LOCALE_SYSTEM_DEFAULT, DATE_SHORTDATE, syst, NULL, wout, BUFSIZ);
outp += WideCharToMultiByte(CP_ACP, (DWORD)NULL, wout, -1, out, BUFSIZ, NULL, NULL) -1;
break;
case 'X' : /* time representation for current locale */
GetTimeFormatW(LOCALE_SYSTEM_DEFAULT, LOCALE_NOUSEROVERRIDE, syst, NULL, wout, BUFSIZ);
outp += WideCharToMultiByte(CP_ACP, (DWORD)NULL, wout, -1, out, BUFSIZ, NULL, NULL) -1;
break;
case 'y' : /* year without century as decimal number 00 - 99 */
GetDateFormatW(LOCALE_SYSTEM_DEFAULT, (DWORD)0, syst, L"yy", wout, BUFSIZ);
outp += WideCharToMultiByte(CP_ACP, (DWORD)NULL, wout, -1, out, BUFSIZ, NULL, NULL) -1;
break;
case 'Y' : /* year with century as decimal number */
outp += sprintf(outp, "%02d", syst->wYear);
break;
case 'z' : /* timezone name or abbreviation, no charachers if unknown */
case 'Z' :
GetTimeZoneInformation(&tz);
outp += WideCharToMultiByte(CP_ACP, (DWORD)NULL, tz.StandardName, -1, out, BUFSIZ, NULL, NULL) -1;
break;
case '%' : /* percent symbol (escaped) */
outp += sprintf(outp, "%s", "%");
break;
default : /* copy character unmodifed to output buffer */
*outp = format[i+1]; outp++;
break;
}
}
i++;
}
if((size_t)strlen(out) <= maxsize) {
strcpy(strDest, out);
return(strlen(strDest));
}
else return(0);
}
开发者ID:luaforge,项目名称:lua4wince,代码行数:101,代码来源:lwince.c
示例16: win32_strftime_helper
//.........这里部分代码省略.........
case 'V':
n = g_date_get_iso8601_week_of_year (d);
g_array_append_vals (result, digits + n/10, 1);
g_array_append_vals (result, digits + n%10, 1);
break;
case 'w':
g_array_append_vals (result, digits + systemtime.wDayOfWeek, 1);
break;
case 'W':
n = g_date_get_monday_week_of_year (d);
g_array_append_vals (result, digits + n/10, 1);
g_array_append_vals (result, digits + n%10, 1);
break;
case 'x':
n = GetDateFormatW (lcid, 0, &systemtime, NULL, NULL, 0);
if (n > 0)
{
g_array_set_size (result, result->len + n);
GetDateFormatW (lcid, 0, &systemtime, NULL, ((wchar_t *) result->data) + result->len - n, n);
g_array_set_size (result, result->len - 1);
}
break;
case 'X':
n = GetTimeFormatW (lcid, 0, &systemtime, NULL, NULL, 0);
if (n > 0)
{
g_array_set_size (result, result->len + n);
GetTimeFormatW (lcid, 0, &systemtime, NULL, ((wchar_t *) result->data) + result->len - n, n);
g_array_set_size (result, result->len - 1);
}
break;
case 'y':
g_array_append_vals (result, digits + (systemtime.wYear/10)%10, 1);
g_array_append_vals (result, digits + systemtime.wYear%10, 1);
break;
case 'Y':
g_array_append_vals (result, digits + systemtime.wYear/1000, 1);
g_array_append_vals (result, digits + (systemtime.wYear/100)%10, 1);
g_array_append_vals (result, digits + (systemtime.wYear/10)%10, 1);
g_array_append_vals (result, digits + systemtime.wYear%10, 1);
break;
case 'Z':
n = GetTimeZoneInformation (&tzinfo);
if (n == TIME_ZONE_ID_UNKNOWN)
;
else if (n == TIME_ZONE_ID_STANDARD)
g_array_append_vals (result, tzinfo.StandardName, wcslen (tzinfo.StandardName));
else if (n == TIME_ZONE_ID_DAYLIGHT)
g_array_append_vals (result, tzinfo.DaylightName, wcslen (tzinfo.DaylightName));
break;
case '%':
g_array_append_vals (result, L"%", 1);
break;
}
}
else if (c <= 0xFFFF)
{
wchar_t wc = c;
g_array_append_vals (result, &wc, 1);
}
else
{
glong nwc;
wchar_t *ws;
ws = g_ucs4_to_utf16 (&c, 1, NULL, &nwc, NULL);
g_array_append_vals (result, ws, nwc);
g_free (ws);
}
p = g_utf8_next_char (p);
}
convbuf = g_utf16_to_utf8 ((wchar_t *) result->data, result->len, NULL, &convlen, NULL);
g_array_free (result, TRUE);
if (!convbuf)
{
s[0] = '\0';
return 0;
}
if (slen <= convlen)
{
/* Ensure only whole characters are copied into the buffer. */
gchar *end = g_utf8_find_prev_char (convbuf, convbuf + slen);
g_assert (end != NULL);
convlen = end - convbuf;
/* Return 0 because the buffer isn't large enough. */
retval = 0;
}
else
retval = convlen;
memcpy (s, convbuf, convlen);
s[convlen] = '\0';
g_free (convbuf);
return retval;
}
开发者ID:thewb,项目名称:mokoiax,代码行数:101,代码来源:gdate.c
示例17: main
DWORD main(int argc, char *argv[])
{
HANDLE hPipe;
SYELOG_MESSAGE Message;
BOOL fSuccess;
DWORD cbWritten, dwMode;
// Try to open a named pipe; wait for it, if necessary.
TIME_ZONE_INFORMATION tzi;
GetTimeZoneInformation(&tzi);
for (;;) {
hPipe = CreateFileW(SYELOG_PIPE_NAMEW, // pipe name
GENERIC_WRITE, // write access only
0, // no sharing
NULL, // no security attributes
OPEN_EXISTING, // opens existing pipe
0, // default attributes
NULL); // no template file
// Break if the pipe handle is valid.
if (hPipe != INVALID_HANDLE_VALUE)
break;
// Exit if an error other than ERROR_PIPE_BUSY occurs.
if (GetLastError() != ERROR_PIPE_BUSY)
MyErrExit("Could not open pipe");
// All pipe instances are busy, so wait for 1
|
请发表评论