convert time interval to an int
| Sat, 2004-01-24 01:09 | |
|
I started by trying to determine the number of hours offset from UTC to local time and I came up with two methods. In both cases I found the TInt tzOffset is set to the same incorrect value, 1068. The same incorrect value both ways leads me to the conclusion that I am incorrectly converting the TTimeInterval to an Int.
The documentation for TTimeIntervalBase::Int() is pretty sketchy. Anyone know how to convert an interval to an int? My app does not use TTime/TDateTime for its date/time handling which seems to be the preferred usage for TTimeInterval math. 1. compute diff between local and UTC TInt tzOffset; TTime localtime, utctime; TTimeIntervalHours aInterval; localtime.HomeTime(); utctime.UniversalTime(); localtime.HoursFrom( utctime, aInterval ); tzOffset= aInterval.Int(); 2. use convenience function from TLocale TLocale locale; // locale object for time zone offset TTimeIntervalSeconds universalTimeOffset( locale.UniversalTimeOffset() ); TInt tzOffset = universalTimeOffset.Int() / 3600; |
|






Forum posts: 1
it worked in my prog.
TTime ti;
TTime ti2;
_LIT(Kson,"20050729:235959.999999");
ti2.Set(Kson);
ti.HomeTime();
TTimeIntervalSeconds ttis;
TInt ttii = ti2.SecondsFrom(ti,ttis);//if equals zero it's O.K.
TTimeIntervalBase tBase(ttis);
TInt saniye = tBase.Int();
str.Num(saniye);
iLabelSaniye->SetTextL(str);