cubicweb #2154813 pb with Datetime/Time handling and NOW rql keyword [open]

the story:

  • cw 3.13 introduced TZDatetime and TZTime types
  • to handle that, we now set database time zone to UTC

but this introduced a flaw : in a lot of place, such as creation_date/modification_date attributes initialization, we are using python datetime.now(), which return timestamp in the local timezone.

This means that if you create an entity in UTC+1, then search for entity whose creation_date is < NOW, you won't find it. This may also create pb when computing interval (such as NOW - creation_date as in tickets table).

I'm not yet sure of the proper way to do that.

The proper way would probably be to use utc everywhere, and to convert it at display time using server time zone (or user specific time zone), but this will probably be an heavy change. In this case we won't need the TZ* types anymore.

Another possibility would be to make NOW and TODAY return different thing according to a context (eg used with TZDatetime or Datetime), but we won't be always able to determine that context.

A last one would be to introduce new UTCNOW / UTCTODAY keywords or similar, and make NOW/TODAY always return timestamp at the server time zone.

If you've an opinion on this, please talk. IMO we should tackle this once for all and choose option 1.

priorityimportant
typebug
done in<not specified>
load2.000
load left2.000
closed by<not specified>