Symbian
Symbian OS Library

SYMBIAN OS V9.3

[Index] [Spacer] [Previous] [Next]



How to implement universal time and home time

These code fragments demonstrate the various components which make up the time, including:


Home time

In the following example code fragment, the universal time offset is added to the universal time, giving the home time. The universal time offset is determined by the time zone, and by whether daylight savings is currently in effect. The offset is in seconds from universal time; this is positive for time zones east of universal time, and negative for time zones west of universal time. Home time is the same time as a wall clock would show, and it is not neccecary to consider daylight savings independently of the time zone.

TTime time;

    // Get Universal time
time.UniversalTime();

    // Get Universal time offset
TTimeIntervalSeconds universalTimeOffset(User::UTCOffset());

    // Add locale's universal time offset to universal time
    // to get the home time
time+=universalTimeOffset;

time now contains the home time. This may be tested by calling TTime::HomeTime(), which should give the same result.

TTime homeTime;
homeTime.HomeTime(); // homeTime==time