# Path: github2/core.py
# @_handle_naive_datetimes
# def datetime_to_ghdate(datetime_):
#     """Convert Python datetime to GitHub date string.
# 
#     :param datetime datetime_: datetime object to convert
# 
#     """
#     return datetime_.strftime(GITHUB_DATE_FORMAT)
# 
# @_handle_naive_datetimes
# def datetime_to_commitdate(datetime_):
#     """Convert Python datetime to GitHub date string.
# 
#     :param datetime datetime_: datetime object to convert
# 
#     """
#     date_without_tz = datetime_.strftime(COMMIT_DATE_FORMAT)
#     utcoffset = GITHUB_TZ.utcoffset(datetime_)
#     hours, minutes = divmod(utcoffset.days * 86400 + utcoffset.seconds, 3600)
# 
#     return "".join([date_without_tz, "%+03d:%02d" % (hours, minutes)])
# 
# def datetime_to_isodate(datetime_):
#     """Convert Python datetime to GitHub date string.
# 
#     :param str datetime_: datetime object to convert
# 
#     .. note:: Supports naive and timezone-aware datetimes
#     """
#     if not datetime_.tzinfo:
#         datetime_ = datetime_.replace(tzinfo=tz.tzutc())
#     else:
#         datetime_ = datetime_.astimezone(tz.tzutc())
#     return "%sZ" % datetime_.isoformat()[:-6]
# 
# def string_to_datetime(string):
#     """Convert a string to Python datetime.
# 
#     :param str github_date: date string to parse
# 
#     """
#     parsed = parser.parse(string)
#     if NAIVE:
#         parsed = parsed.replace(tzinfo=None)
#     return parsed


from datetime import datetime as dt
from nose.tools import eq_
from github2.core import (datetime_to_ghdate, datetime_to_commitdate,
                          datetime_to_isodate, string_to_datetime)
        '2011-04-09T10:05:58-07:00')
    eq_(datetime_to_commitdate(dt(2011, 4, 9, 9, 53, 0)),
        '2011-04-09T09:53:00-07:00')
    eq_(datetime_to_commitdate(dt(2011, 4, 9, 10, 0, 21)),
        '2011-04-09T10:00:21-07:00')
    #eq_(datetime_to_commitdate(dt(2010, 12, 16, 15, 10, 59)),
    #    '2010-12-16T15:10:59-08:00')
    eq_(datetime_to_commitdate(dt(2011, 4, 9, 9, 53, 0)),
        '2011-04-09T09:53:00-07:00')
    eq_(datetime_to_commitdate(dt(2011, 4, 9, 9, 53, 0)),
        '2011-04-09T09:53:00-07:00')


def test_isodate_to_datetime():
    eq_(string_to_datetime('2011-05-22T00:24:15Z'), dt(2011, 5, 22, 0, 24, 15))
    eq_(string_to_datetime('2011-04-09T10:07:30Z'), dt(2011, 4, 9, 10, 7, 30))
    eq_(string_to_datetime('2011-02-19T07:16:11Z'), dt(2011, 2, 19, 7, 16, 11))
    eq_(string_to_datetime('2010-12-21T12:34:27Z'),
        dt(2010, 12, 21, 12, 34, 27))
    eq_(string_to_datetime('2011-04-09T10:20:05Z'), dt(2011, 4, 9, 10, 20, 5))
    eq_(string_to_datetime('2011-04-09T10:05:58Z'), dt(2011, 4, 9, 10, 5, 58))
    eq_(string_to_datetime('2011-04-09T09:53:00Z'), dt(2011, 4, 9, 9, 53, 0))
    eq_(string_to_datetime('2011-04-09T10:00:21Z'), dt(2011, 4, 9, 10, 0, 21))
    eq_(string_to_datetime('2010-12-16T15:10:59Z'),
        dt(2010, 12, 16, 15, 10, 59))
    eq_(string_to_datetime('2011-04-09T09:53:00Z'), dt(2011, 4, 9, 9, 53, 0))
    eq_(string_to_datetime('2011-04-09T09:53:00Z'), dt(2011, 4, 9, 9, 53, 0))


def test_datetime_to_isodate():

# Path: github2/core.py
# @_handle_naive_datetimes
# def datetime_to_ghdate(datetime_):
#     """Convert Python datetime to GitHub date string.
# 
#     :param datetime datetime_: datetime object to convert
# 
#     """
#     return datetime_.strftime(GITHUB_DATE_FORMAT)
# 
# @_handle_naive_datetimes
# def datetime_to_commitdate(datetime_):
#     """Convert Python datetime to GitHub date string.
# 
#     :param datetime datetime_: datetime object to convert
# 
#     """
#     date_without_tz = datetime_.strftime(COMMIT_DATE_FORMAT)
#     utcoffset = GITHUB_TZ.utcoffset(datetime_)
#     hours, minutes = divmod(utcoffset.days * 86400 + utcoffset.seconds, 3600)
# 
#     return "".join([date_without_tz, "%+03d:%02d" % (hours, minutes)])
# 
# def datetime_to_isodate(datetime_):
#     """Convert Python datetime to GitHub date string.
# 
#     :param str datetime_: datetime object to convert
# 
#     .. note:: Supports naive and timezone-aware datetimes
#     """
#     if not datetime_.tzinfo:
#         datetime_ = datetime_.replace(tzinfo=tz.tzutc())
#     else:
#         datetime_ = datetime_.astimezone(tz.tzutc())
#     return "%sZ" % datetime_.isoformat()[:-6]
# 
# def string_to_datetime(string):
#     """Convert a string to Python datetime.
# 
#     :param str github_date: date string to parse
# 
#     """
#     parsed = parser.parse(string)
#     if NAIVE:
#         parsed = parsed.replace(tzinfo=None)
#     return parsed


# Path: tests/test_date_handling.py
from datetime import datetime as dt
from nose.tools import eq_
from github2.core import (datetime_to_ghdate, datetime_to_commitdate,
                          datetime_to_isodate, string_to_datetime)

        '2011-04-09T10:05:58-07:00')
    eq_(datetime_to_commitdate(dt(2011, 4, 9, 9, 53, 0)),
        '2011-04-09T09:53:00-07:00')
    eq_(datetime_to_commitdate(dt(2011, 4, 9, 10, 0, 21)),
        '2011-04-09T10:00:21-07:00')
    #eq_(datetime_to_commitdate(dt(2010, 12, 16, 15, 10, 59)),
    #    '2010-12-16T15:10:59-08:00')
    eq_(datetime_to_commitdate(dt(2011, 4, 9, 9, 53, 0)),
        '2011-04-09T09:53:00-07:00')
    eq_(datetime_to_commitdate(dt(2011, 4, 9, 9, 53, 0)),
        '2011-04-09T09:53:00-07:00')


def test_isodate_to_datetime():
    eq_(string_to_datetime('2011-05-22T00:24:15Z'), dt(2011, 5, 22, 0, 24, 15))
    eq_(string_to_datetime('2011-04-09T10:07:30Z'), dt(2011, 4, 9, 10, 7, 30))
    eq_(string_to_datetime('2011-02-19T07:16:11Z'), dt(2011, 2, 19, 7, 16, 11))
    eq_(string_to_datetime('2010-12-21T12:34:27Z'),
        dt(2010, 12, 21, 12, 34, 27))
    eq_(string_to_datetime('2011-04-09T10:20:05Z'), dt(2011, 4, 9, 10, 20, 5))
    eq_(string_to_datetime('2011-04-09T10:05:58Z'), dt(2011, 4, 9, 10, 5, 58))
    eq_(string_to_datetime('2011-04-09T09:53:00Z'), dt(2011, 4, 9, 9, 53, 0))
    eq_(string_to_datetime('2011-04-09T10:00:21Z'), dt(2011, 4, 9, 10, 0, 21))
    eq_(string_to_datetime('2010-12-16T15:10:59Z'),
        dt(2010, 12, 16, 15, 10, 59))
    eq_(string_to_datetime('2011-04-09T09:53:00Z'), dt(2011, 4, 9, 9, 53, 0))
    eq_(string_to_datetime('2011-04-09T09:53:00Z'), dt(2011, 4, 9, 9, 53, 0))


def test_datetime_to_isodate():

    eq_(datetime_to_isodate(dt(2011, 5, 22, 0, 24, 15)),