188 return self._value |
188 return self._value |
189 |
189 |
190 class date(mappable, wrapped): |
190 class date(mappable, wrapped): |
191 """Wrapper for date tuple""" |
191 """Wrapper for date tuple""" |
192 |
192 |
193 def __init__(self, value): |
193 def __init__(self, value, showfmt='%d %d'): |
194 # value may be (float, int), but public interface shouldn't support |
194 # value may be (float, int), but public interface shouldn't support |
195 # floating-point timestamp |
195 # floating-point timestamp |
196 self._unixtime, self._tzoffset = map(int, value) |
196 self._unixtime, self._tzoffset = map(int, value) |
|
197 self._showfmt = showfmt |
197 |
198 |
198 def contains(self, context, mapping, item): |
199 def contains(self, context, mapping, item): |
199 raise error.ParseError(_('date is not iterable')) |
200 raise error.ParseError(_('date is not iterable')) |
200 |
201 |
201 def getmember(self, context, mapping, key): |
202 def getmember(self, context, mapping, key): |
209 |
210 |
210 def join(self, context, mapping, sep): |
211 def join(self, context, mapping, sep): |
211 raise error.ParseError(_("date is not iterable")) |
212 raise error.ParseError(_("date is not iterable")) |
212 |
213 |
213 def show(self, context, mapping): |
214 def show(self, context, mapping): |
214 return '%d %d' % (self._unixtime, self._tzoffset) |
215 return self._showfmt % (self._unixtime, self._tzoffset) |
215 |
216 |
216 def tomap(self, context): |
217 def tomap(self, context): |
217 return {'unixtime': self._unixtime, 'tzoffset': self._tzoffset} |
218 return {'unixtime': self._unixtime, 'tzoffset': self._tzoffset} |
218 |
219 |
219 def tobool(self, context, mapping): |
220 def tobool(self, context, mapping): |