def render(self, obj): value = self.get_value(obj) if value in (NO_VALUE, None): return u"" datetime = datify(value) tlc = obj.unrestrictedTraverse('@@plone').toLocalizedTime return translate(tlc(datetime))
def EffectiveDate(self, zone=None): # Dublin Core Date element - date resource becomes effective. if zone is None: zone = _zone ed = getattr(self, 'effective_date', None) ed = datify(ed) return ed and ed.toZone(zone).ISO() or 'None'
def ExpirationDate(self, zone=None): # Dublin Core Date element - date resource expires. if zone is None: zone = _zone ed = getattr(self, 'expiration_date', None) ed = datify(ed) return ed and ed.toZone(zone).ISO() or 'None'
def setModificationDate(self, modification_date=None): # Set the date when the resource was last modified. # When called without an argument, sets the date to now. if modification_date is None: self.modification_date = DateTime() else: self.modification_date = datify(modification_date)
def effective(self): # Dublin Core Date element - date resource becomes effective. date = getattr(self, 'effective_date', _marker) if date is _marker: date = getattr(self, 'creation_date', None) date = datify(date) return date is None and FLOOR_DATE or date
def due_case(obj): """ :return: value of field due for cases """ date = getattr(obj, 'due', None) date = datify(date) return date is None and datetime.max or date
def modified(self): # Dublin Core Date element - date resource last modified. date = self.modification_date if date is None: # Upgrade. date = DateTime(self._p_mtime) self.modification_date = date date = datify(date) return date
def CreationDate(self, zone=None): # Dublin Core Date element - date resource created. if zone is None: zone = _zone # return unknown if never set properly if self.creation_date: date = datify(self.creation_date) return date.toZone(zone).ISO() else: return 'Unknown'
def Date(self, zone=None): # Dublin Core Date element - default date. if zone is None: zone = _zone # Return effective_date if set, modification date otherwise date = getattr(self, 'effective_date', None) if date is None: date = self.modified() date = datify(date) return date.toZone(zone).ISO()
def modified(self): connection = self.getConnection() if not connection or not 'modification_date' in connection.fieldnames.keys(): return super(SQLDexterityItem, self).modified() # Dublin Core Date element - date resource last modified. date = self.modification_date if date is None: # Upgrade. if self._p_mtime: date = self._p_mtime else: date = datetime.datetime.now() self.modification_date = date date = datify(date) return date
def modified(self): connection = self.getConnection() if not connection or not 'modification_date' in connection.fieldnames.keys( ): return super(SQLDexterityItem, self).modified() # Dublin Core Date element - date resource last modified. date = self.modification_date if date is None: # Upgrade. if self._p_mtime: date = self._p_mtime else: date = datetime.datetime.now() self.modification_date = date date = datify(date) return date
def due(obj): date = getattr(obj, "due", None) date = datify(date) return date is None and datetime.max or date
def created(self): # Dublin Core Date element - date resource created. # allow for non-existent creation_date, existed always date = getattr(self, 'creation_date', None) date = datify(date) return date is None and FLOOR_DATE or date
def ModificationDate(self, zone=None): # Dublin Core Date element - date resource last modified. if zone is None: zone = _zone date = datify(self.modified()) return date.toZone(zone).ISO()
def expires(self): # Dublin Core Date element - date resource expires. date = getattr(self, 'expiration_date', None) date = datify(date) return date is None and CEILING_DATE or date
def due(obj): date = getattr(obj, 'due', None) date = datify(date) return date is None and datetime.max or date
def setEffectiveDate(self, effective_date): # Set Dublin Core Date element - date resource becomes effective. self.effective_date = datify(effective_date)
def setExpirationDate(self, expiration_date): # Set Dublin Core Date element - date resource expires. self.expiration_date = datify(expiration_date)