Ticket #13362 (confirmed Bug)

Opened 3 years ago

Last modified 3 years ago

Archetypes and DateTime.strftime() are not compatible

Reported by: csenger Owned by:
Priority: minor Milestone: 4.x
Component: Archetypes Version: 4.2
Keywords: DateTime Cc: dimboo, ida

Description (last modified by ida) (diff)

Archetypes has a fallback date in Products.Archetypes.ExtensibleMetadata

FLOOR_DATE = DateTime(1000, 1)  # always effective

that it uses for the effectiveDate field. Unfortunately this cannot be strftime()d cause DateTime uses pythons datetime.datetime since Version 2.11 that needs year to be >1900:

(Pdb) from Products.Archetypes.ExtensibleMetadata import FLOOR_DATE
(Pdb) FLOOR_DATE.strftime('%Y-%M')
*** ValueError: year=1000 is before 1900; the datetime strftime() methods require year >= 1900

If effectiveDate is not set/None, ExtensibleMetadata.effective returns FLOOR_DATE. strftime() this, e.g. through toLocalizedTime(), does not work. Plone views and templates are not affected. E.g. plone.app.search:search.pt uses ExtensibleMetadata.EffectiveDate(). This method returns the string 'None'.

Places that break are e.g.

Same goes for the expiration-date, which falls back on year 2500.

Change History

comment:1 Changed 3 years ago by kleist

  • Status changed from new to confirmed
  • Component changed from Unknown to Archetypes

comment:2 Changed 3 years ago by dimboo

  • Cc dimboo added

comment:3 Changed 3 years ago by ida

  • Keywords DateTime added
  • Cc ida added
  • Description modified (diff)

comment:4 Changed 3 years ago by ida

Proposing to set the effective- and the expiration-date to the creation-date-value during creation. Makes semantically sense, imho (yes, it is published and expired in the moment of birth, if no user decides differently) and resolves the conflicts.

Approvals or objections anyone?

Note: See TracTickets for help on using tickets.