[Kde-pim] Fwd: deprecated calls in kdepimlibs
David Jarvie
lists at astrojar.org.uk
Wed Jan 17 18:29:11 GMT 2007
Hi Didier,
Sorry it's taken so long to reply.
On Friday 12 January 2007 18:57, didier chagniot wrote:
> * the first point seems easy to solve: use of KDateTime::fromString(string,
> Format=QDateTime).
KDateTime::fromString() is only guaranteed to work if a time zone offset is
specified in the string, but since the existing code uses
QDateTime::fromString(), that can't be the case. You need to establish which
time zone is being used, and then probably call
KDateTime( QDateTime::fromString(...), [TIMEZONE] );
Even then, if UTC is involved, you need to be very careful about conversions
of UTC to/from local time.
> * For the second point I've read the deprecated code :
> setDtEnd( QDateTime::fromString( s ) ).
> The time zone is local (UTC) or dtStart().timeSpec() is used (if valid).
>
> in formatter.cpp, two lines above setDtEnd( QDateTime::fromString( s ) ),
> setDtStart is set:
> event->setDtStart( QDateTime::fromString( s ) ); // ## Format??
>
> Should I put :
> ------------------------------------------------------
> setFromStringDefault(event->dtStart().timeSpec());
> event->setDtEnd( KDateTime::fromString(s, Format=QDateTime));
> ------------------------------------------------------
> instead of :
> event->setDtEnd( QDateTime::fromString( s ) );
I notice that there is a deprecated form of setDtStart() immediately before
the setDtEnd(). That call also needs to be replaced in the same way as the
setDtEnd() call. It's probable (although not absolutely guaranteed without
checking the RFC) that they will both use the same time zone.
In order to remove the deprecated calls, you need to determine exactly which
time zone the input text assumes. For this, you need to refer to the RFC
which defines the input format, or ask one of the kdepim developers who
knows. It's quite likely that it will be UTC, but it might be the local time
zone, or perhaps even something else. There's no way to do it properly
without being sure.
Once you've found this out, you should read the KDateTime API documentation
for the relevant functions thoroughly before writing the new code. It's very
easy to get things wrong if you are converting QDateTime values to/from UTC.
You've picked on a somewhat difficult topic here, so if you need further help
once you've found out what time zones should be used, just ask.
--
David Jarvie.
KAlarm author and maintainer.
http://www.astrojar.org.uk/linux/kalarm.html
_______________________________________________
kde-pim mailing list
kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
kde-pim home page at http://pim.kde.org/
More information about the kde-pim
mailing list