Creating a User-Defined Time Zone

This tutorial describes how a device creator creates a user-defined time zone using CTzUserData .

The high-level steps to create a user-defined time zone are described in Procedure section:
  1. Create the TZ rules object using CTzRules::NewL() .
  2. Use the CTzUserNames::NewL() function to create a TZ names object.
  3. Connect to the TZ server using RTz::Connect() .
  4. Create a user-defined time zone using CTzUserData::CreateL() .

An illustration of the procedure is given below. Note that cleanup stack management and CTzRules object creation details are omitted for clarity.

       #include <tz.h> // For CTzUserData etc.
#include <…>

...

// These strings would typically be supplied by the UI 
layer.
_LIT( KTzUserStdName,      ”Mountain Standard Time” );
_LIT( KTzUserShortStdName, ”MST” );
_LIT( KTzUserDstName,      ”Mountain Daylight Time” );
_LIT( KTzUserShortDstName, ”MDT” );
_LIT( KTzUserCityName,     ”Window Rock” );
_LIT( KTzUserRegionName,   ”America” );

// Create TZ rules object.
CTzRules* tzRules = ...;

// Create TZ names object.
CTzUserNames* tzNames = CTzUserNames::NewL( KTzUserStdName,
                                            KTzUserShortStdName,
                                            KTzUserDstName,
                                            KTzUserShortDstName,
                                            KTzUserCityName,
                                            KTzUserRegionName );

// Connect to TZ Server.
RTz tzServer;
User::LeaveIfError( tzServer.Connect() );

// Create user-defined TZ.
CTzUserData* tzUserData = CTzUserData::NewL( tzServer );
CTzId* userTzId = tzUserData->CreateL( *tzRules, *tzNames );

...