Add fancy date format option to KLocale

Pino Toscano toscano.pino at tiscali.it
Sun Apr 8 19:25:22 BST 2007


Alle 15:38, domenica 8 aprile 2007, David Jarvie ha scritto:
> > > QString formatDate(const QDate&, DateFormat = ShortDate);
> > > QString formatDateTime(const QDateTime&, DateFormat = ShortDate,
> > >     bool includeSeconds = false);
> > > QString formatDateTime(const KDateTime&, DateFormat = ShortDate,
> > >     bool includeSeconds = false, bool includeTimeZone = false);
> >
> > We "officially dislike" boolean arguments if their meaning is unclear
> > when somebody reads the code. You could add more enum elements and maybe
> > make flags (as in QFlags) out of all boolean options if that looks
> > advantageous.
>
> I did think of combining the other boolean parameters with the first one,
> but mainly because of shortage of time I didn't bother. But you're right -
> it should be done at the same time as changing the first bool parameter.
> I'll expand the enum:
>
> enum DateFormat {
>   ShortDate, LongDate, FancyDate
>   TimeZone,
>   Seconds
> };
>
> and declare
>
> Q_DECLARE_FLAGS(DateTimeFormat, DateFormat)

From what I see, maybe it would be better have two different enums, one for 
the type (ShortData, LongDate, ColloquialDate) - without flag - and another 
one for the options, like:

enum DateTimeFormatOption {
  NoOption = 0;
  TimeZone = 1;
  Seconds = 2;
};
Q_DECLARE_FLAGS(DateTimeFormatOptions, DateTimeFormatOption)
maybe the names are too long - suggestion are welcome ;)

Otherwise, with a single flag'ed enum I could call with eg ShortDate | 
LongDate, that does not make sense IMHO.

-- 
Pino Toscano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20070408/25a318a9/attachment.sig>


More information about the kde-core-devel mailing list