I created an indexer to add a date to the portal_catalog and later get the value of the catalog index to test, if a Dexterity object starts not before the indexed time.
Here the indexer:
@indexer(IProgram)
def programStartIndexer(obj):
if obj.start is None:
return None
return DateTime(obj.start).ISO()
And the invariant in the Dexterity object:
@invariant
def validateStartNotBeforeProgram(data):
if data.trackstart is not None:
catalog = api.portal.get_tool(name='portal_catalog')
result = catalog.uniqueValuesFor('programstart')
if DateTime(data.trackstart) < DateTime(result[0]):
raise StartBeforeConferenceProgram(
_(u"The start date could not before the begin of the conference program."))
The value in the catalog index get a time stamp of 'GMT+0' and the 'data.trackstart' get a time stamp 'GMT+2'. The fields in the Dexterity fields are identical (except naming and description) (the source of the indexer and the field 'trackstart').
Because the indexed value (it should also be indexed equivalent to the local time, which could be GMT-2 as well as another time zone) was assigned to UTC, the test about the start time of the track failed.
Questions:
a) If I index a date and time value to the catalog, will it get always the UTC timezone?
b) If it didn't get always this timezone, is there some info about the way to achieve that?
c) If the indexed timezone is always UTC, is there info about a way to calculate the value equivalent to local timezone and index this calculated value?
Thanks in advance for any hints,
Andreas