#!/usr/bin/env python
"""
$URL: svn+ssh://svn.mems-exchange.org/repos/trunk/qp/lib/test/utest_tz.py $
$Id: utest_tz.py 28672 2006-08-30 00:53:48Z dbinger $
"""
from datetime import datetime, timedelta
from qp.lib import tz
from sancho.utest import UTest


class Test(UTest):

    def a(self):
        eastern = datetime(
            year=2000, month=12, day=1, hour=10,
            tzinfo=tz.Eastern)
        central = eastern.astimezone(tz.Central)
        mountain = eastern.astimezone(tz.Mountain)
        pacific = eastern.astimezone(tz.Pacific)
        assert eastern.hour == central.hour + 1
        assert eastern.hour == mountain.hour + 2
        assert eastern.hour == pacific.hour + 3
        utc = eastern.astimezone(tz.UTC)
        utc_plus_1 = eastern.astimezone(tz.UTC_plus_1)
        assert utc.hour == eastern.hour + 5
        est = datetime(
            year=2000, month=6, day=1, hour=18,
            tzinfo=tz.Eastern)
        utc2 = est.astimezone(tz.UTC)
        assert utc2.hour == est.hour + 4
        eastern_now = tz.Eastern.now()
        central_now = tz.Eastern.now()
        print  central_now - eastern_now < timedelta(seconds=1)

if __name__ == '__main__':
    Test()
