Pylons

s0undt3ch
Aug 17, 2007 6:27:24 PM

UTC Localized DateTime Object from SqlAlchemy

Language: Python
1
2
3
4
5
6
7
8
9
import sqlalchemy as sqla
from pytz import UTC

class UTCDateTime(sqla.types.TypeDecorator):
    impl = sqla.types.DateTime
    def convert_bind_param(self, value, engine):
        return value
    def convert_result_value(self, value, engine):
        return UTC.localize(value)

Download

Comments (0)

You must login before you can comment.

Powered by Pylons - Contact Administrators