view backend/couchdb/ListDateTimeField.py @ 235:a34cb404cef3

remove the Ui_ prefix from the Qt designer files - The eric IDE will add it without any configuration. Rewrite the Makefile to behave as eric.
author Dirk Olmes <dirk@xanthippe.ping.de>
date Mon, 26 Jan 2015 13:38:55 +0100
parents e34c53a3e407
children
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