view backend/couchdb/ListDateTimeField.py @ 214:b0de75d57e78

Merge with 1ac0b8e2feae3bd8336dded8247ae201b13d9ca1
author dirk
date Sat, 04 May 2013 06:23:20 +0200
parents f0afcd1c5656
children bb3c851b18b1
line wrap: on
line source


from couchdb.mapping import Field
from datetime import datetime

class ListDateTimeField(Field):
    def _to_python(self, value):
        if isinstance(value, list):
            return datetime(*value)
        return value

    def _to_json(self, value):
        if isinstance(value, datetime):
            return [ value.year, value.month, value.day, value.hour, value.minute, value.second ]
        return value