In addition to providing access to the various Outlook folder objects, the IPOutlookApp interface has two support functions that are used for handling time zone information. The first function, IPOutlookApp::GetTimeZoneInformationFromIndex(), uses the standard Windows CE TIME_ZONE_INFORMATION structure to retrieve time zone information. The function is defined as follows:
HRESULT IPOutlookApp::GetTimeZoneInformationFromIndex(int cTimezone, TIME_ZONE_INFORMATION *ptzInfo);
The Pocket Outlook Object Model also provides the ITimeZone interface, which is used for retrieving information about daylight savings time for a particular time zone. To get a pointer to the ITimeZone object, you can use the following function:
HRESULT IPOutlookApp::GetTimeZoneFromIndex(int cTimezone, ITimeZone **ppTz);
The first parameter is the index to the time zone that you are interested in, and is followed by a pointer to a pointer value that will be filled in with the ITimeZone interface.
Table 10.3 describes the properties supported by the ITimeZone interface.
Property | Get/Put | Description |
---|---|---|
Application | Get | Returns a pointer to the IPOutlookApp interface. |
Bias | Get | Gets the current bias, in minutes, for the local time translations (UTC = Local Time + Bias). |
DaylightBias | Get | Gets the offset, in minutes, when a time zone is in daylight savings time. |
DaylightDate | Get | Gets the date when the time returns to daylight savings time. |
DaylightDayOfWeekMask | Get | Gets the day of the week on which daylight savings time begins. |
DaylightInstance | Get | Gets the week of the month in which daylight savings time begins. |
DaylightMonthOfYear | Get | Gets the month of the year in which daylight savings time begins. |
DaylightName | Get | Gets the name of the time zone when in daylight savings time. |
IsDaylightAbsoluteDate | Get | Indicates whether the daylight date is the absolute or relative date. Returns TRUE if it is the standard date, FALSE if it is relative. |
IsStandardAbsoluteDate | Get | Indicates whether the standard date is the absolute or relative date. Returns TRUE if it is the standard date, FALSE if it is relative. |
StandardBias | Get | Gets the offset, in minutes, when a time zone is in standard time. |
StandardDate | Get | Indicates when the date returns to a standard time. |
StandardDayOfWeekMask | Get | Gets the day of the week on which standard time returns from daylight savings time. |
StandardInstance | Get | Gets the week of the month (from 1 to 5) in which standard time begins. |
StandardMonthOfYear | Get | Gets the month of the year in which standard time begins. |
StandardName | Get | Gets the name of the time zone when in standard time. |
SupportsDST | Get | Indicates whether the time zone supports daylight savings time. |
The following short code example shows how you can get time zone information for Pacific Standard Time:
// Get the time zone information for PST ITimeZone *pTimeZone = NULL; hr = pOlApp->GetTimeZoneFromIndex(4, &pTimeZone); if(FAILED(hr)) OutputDebugString(TEXT("Could not get the calendar folder")); else { TCHAR tchDaylightStart[256] = TEXT("\0"); TCHAR tchStandardStart[256] = TEXT("\0"); // Figure out daylight savings time BSTR bstrName = NULL; SYSTEMTIME stDaylight; VARIANT_BOOL vbDate; hr = pTimeZone->get_DaylightName(&bstrName); if(FAILED(hr)) return FALSE; // PST uses a relative date, but let's just make sure pTimeZone->get_IsDaylightAbsoluteDate(&vbDate); if(vbDate == VARIANT_FALSE) { DATE pDaylight = NULL; LONG lDayOfWeek = 0, lMonth = 0, lDayInstance = 0; // Get the date if(FAILED(pTimeZone->get_DaylightDayOfWeekMask (&lDayOfWeek))) return FALSE; if(FAILED(pTimeZone->get_DaylightInstance (&lDayInstance))) return FALSE; if(FAILED(pTimeZone->get_DaylightMonthOfYear(&lMonth))) return FALSE; // Get the time if(FAILED(pTimeZone->get_DaylightDate(&pDaylight))) return FALSE; // Fill out the structure: memset(&stDaylight, 0, sizeof(SYSTEMTIME)); VariantTimeToSystemTime(pDaylight, &stDaylight); wsprintf(tchDaylightStart, TEXT("%s\r\nDaylight Savings Time will begin:\r\nWeek: %d\r\nDay of Week: %d\r\nMonth: %d\r\nat %d:%d"), bstrName, lDayOfWeek, lDayInstance, lMonth, stDaylight.wHour, stDaylight.wMinute); } else { // Place absolute date handler stuff here } // MessageBox MessageBox(NULL, tchDaylightStart, TEXT("Daylight"), MB_OK); // Free resources SysFreeString(bstrName); } if(pTimeZone) pTimeZone->Release();