[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-pim
Subject:    RE: [Kde-pim] Stuck in time zones
From:       "Best, Jan-Pascal van" <j.p.vanbest () tbm ! tudelft ! nl>
Date:       2002-09-05 9:05:11
[Download RAW message or body]

> There's some code in kicker's clock you can look at. I stole it from
> somewhere else in KDE, can't remember where.
Thanks. In the end, I used the functions in libical for this. They're a
bit
nicer in that they restore the TZ environment variable after use. Still
not
thread/multiprocessing safe though, I'd think.

For the record, this can be use in KDE-PIM to convert UTC times to
a timezone. We really should disect the code in libical and put some
code like this in KRFCDate or something like that, for everyone else to
use.

QDateTime utcAsZone( const QDateTime& utc, const QString& timeZoneId )
{
  QDateTime epoch;
  epoch.setTime_t( 0 );
  time_t v = epoch.secsTo( utc );
  struct icaltimetype tt = icaltime_from_timet( v, 0 ); // 0:
is_date=false
  int offset = icaltime_utc_offset( tt, timeZoneId.local8Bit() );
  return utc.addSecs( offset );
}

Cheers

Jan-Pascal
_______________________________________________
kde-pim mailing list
kde-pim@mail.kde.org
http://mail.kde.org/mailman/listinfo/kde-pim
kde-pim home page at http://pim.kde.org/
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic