view backend/couchdb/ListDateTimeField.py @ 226:016c89dfd488

use our generic PyQtLib instead of custom Qt models in this project
author Dirk Olmes <dirk@xanthippe.ping.de>
date Thu, 22 May 2014 06:10:05 +0200 (2014-05-22)
parents bb3c851b18b1
children e34c53a3e407
line wrap: on
line source
# -*- coding: utf-8 -*-
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