[PATCH] Extend KDateTime with a fancyString()
David Jarvie
lists at astrojar.org.uk
Fri Apr 6 12:42:08 BST 2007
On Thursday 05 April 2007 20:44:28 David Jarvie wrote:
> On Thursday 5 April 2007 17:58, Tom Albers wrote:
> > I extracted the fancy date handling from kmime's date formatter and added
> > it to
> > KDateTime. I think it belongs to this class and not to kmime.
> >
> > I would appreciate if someone looked if it's ok, so I can commit.
>
> IMHO the function doesn't belong in KDateTime in its current form, since
> it's basically processes QDateTime values without proper regard for time
> zones/UTC offsets. There should be output options to allow time zones/UTC
> offsets in its output. I think that it should be generalised to use the
> KDateTime string formatting functions with suitable substitutions for
> recent dates, and allow for output of time zone information. It would be
> better to define another member of the TimeFormat enum to specify a fancy
> date/time output, and integrate the (modified) code into the existing
> toString(TimeFormat) function.
I've been thinking further about this, and now see two preferable approaches:
The function may (in its current form) belong better in KLocale. It's really a
modified form of KLocale::formatDateTime() where sometimes the date part is
substituted by a word representing the day, although if we want to do the day
substitution on the basis of the time zone of the specified date/time
instance (rather than the user's time zone), it would need to take a
KDateTime parameter rather than QDateTime.
Alternatively, or additionally, it could be fitted into
KDateTime::toString(const QString& format), with additional codes being
introduced to output the date or date/time formatted according to locale,
with fancy and short options. This would allow proper use to be made of the
KDateTime value by enabling time zones etc. to be included in the output
string, or not, as desired.
--
David Jarvie.
KAlarm author and maintainer.
http://www.astrojar.org.uk/kalarm
More information about the kde-core-devel
mailing list