def publication_effective_date(self, value): """Publication effective date setter""" value = gmtime(value) dc = IZopeDublinCore(self.__parent__, None) # pylint: disable=invalid-name if value: if (self._first_publication_date is None) or (self._first_publication_date > value): self._first_publication_date = value if dc is not None: dc.effective = value elif self._publication_effective_date: if dc is not None: del dc._mapping['Date.Effective'] # pylint: disable=protected-access self._publication_effective_date = value
def handle_workflow_version_transition(event): """Handle workflow version transition""" principal = event.principal factory = get_object_factory(IWorkflowStateHistoryItem) if factory is not None: item = factory(date=gmtime(datetime.utcnow()), source_version=IWorkflowState( event.old_object).version_id, source_state=event.source, target_state=event.destination, transition_id=event.transition.transition_id, principal=principal.id if IPrincipalInfo.providedBy(principal) else principal, comment=event.comment) IWorkflowState(event.object).history.append(item) # pylint: disable=no-member
def parse_date(value): """Get date specified in unicode ISO format to Python datetime object Dates are always assumed to be stored in GMT timezone :param str value: unicode date to be parsed :return: datetime; the specified value, converted to datetime >>> from pyams_utils.date import parse_date >>> parse_date('2016-11-15T10:13:12+00:00') datetime.datetime(2016, 11, 15, 10, 13, 12, tzinfo=<StaticTzInfo 'GMT'>) >>> parse_date(None) is None True """ if value is not None: return gmtime(parseDatetimetz(value)) return None
def unidate(value): """Get specified date converted to unicode ISO format Dates are always assumed to be stored in GMT timezone :param date value: input date to convert to unicode :return: unicode; input date converted to unicode >>> from datetime import datetime >>> from pyams_utils.date import unidate >>> value = datetime(2016, 11, 15, 10, 13, 12) >>> unidate(value) '2016-11-15T10:13:12+00:00' >>> unidate(None) is None True """ if value is not None: value = gmtime(value) return value.isoformat('T') return None
def push_end_date_index(self): """Push end date getter""" value = self.push_end_date or self.publication_expiration_date if value is None: value = datetime(9999, 12, 31, 11, 59, 59, 999999, GMT) return gmtime(value)
def publication_date(self, value): """Publication date setter""" self._publication_date = gmtime(value)