[Development] QDateTime is missing shared null optimization

Thiago Macieira thiago.macieira at intel.com
Sun Aug 2 19:43:45 CEST 2015


On Sunday 02 August 2015 10:04:36 Thiago Macieira wrote:
> How often do people construct a QDateTime containing only a QDate as a 
> stepping stone to a full QDateTime? Note that the QDateTime constructor 
> containing a QDate sets a valid time; you can only get valid date and null 
> time if you use the constructor with QTime and pass an invalid time, so I'd 
> advocate that you should suffer and allocate memory if you do that.
> > Also OffsetFromUTC supports weird offsets that are not 15 minute
> > intervals.
> 
> True, but there aren't any official timezones outside a quarter-hour
> boundary.  So a 7-bit combined offset & timespec should be enough for most
> use-cases. If you need more, you'll get it, but will cause memory
> allocation.

Actually, we can also combine the invalid date and invalid time in the same 7-
bit field.

For the quarter hour offsets ranging from (-12 * 4) =-48 to (+13.75 * 4) = 55, 
that leaves 25 individual values for the timespec. One of them can be "date 
only", which refers to a given date in any timezone, not a particular one. 

The same applies to time-only, but I'm scratching my head on the combinations 
of time-only QDateTime and changing timezones...

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Development mailing list