# 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)
    eq_(string_to_datetime('2010/06/20 06:13:37 -0700'),
        dt(2010, 6, 20, 6, 13, 37))
    eq_(string_to_datetime('2010/07/28 12:56:51 -0700'),
        dt(2010, 7, 28, 12, 56, 51))
    eq_(string_to_datetime('2010/09/20 21:32:49 -0700'),
        dt(2010, 9, 20, 21, 32, 49))


def test_datetime_to_ghdate():
    eq_(datetime_to_ghdate(dt(2011, 5, 22, 0, 24, 15)),
        '2011/05/22 00:24:15 -0700')

    eq_(datetime_to_ghdate(dt(2009, 4, 18, 20, 4, 9)),
        '2009/04/18 20:04:09 -0700')
    #eq_(datetime_to_ghdate(dt(2009, 11, 13, 4, 15, 17)),
    #    '2009/11/13 04:15:17 -0800')
    #eq_(datetime_to_ghdate(dt(2009, 11, 13, 4, 16, 20)),
    #    '2009/11/13 04:16:20 -0800')
    eq_(datetime_to_ghdate(dt(2010, 4, 18, 0, 24, 29)),
        '2010/04/18 00:24:29 -0700')
    eq_(datetime_to_ghdate(dt(2010, 5, 18, 13, 10, 36)),
        '2010/05/18 13:10:36 -0700')
    eq_(datetime_to_ghdate(dt(2010, 5, 26, 5, 59, 37)),
        '2010/05/26 05:59:37 -0700')
    eq_(datetime_to_ghdate(dt(2010, 5, 27, 0, 8, 41)),
        '2010/05/27 00:08:41 -0700')
    eq_(datetime_to_ghdate(dt(2010, 6, 20, 13, 13, 37)),
        '2010/06/20 13:13:37 -0700')
    eq_(datetime_to_ghdate(dt(2010, 7, 28, 19, 56, 51)),
        '2010/07/28 19:56:51 -0700')

# 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)

    eq_(string_to_datetime('2010/06/20 06:13:37 -0700'),
        dt(2010, 6, 20, 6, 13, 37))
    eq_(string_to_datetime('2010/07/28 12:56:51 -0700'),
        dt(2010, 7, 28, 12, 56, 51))
    eq_(string_to_datetime('2010/09/20 21:32:49 -0700'),
        dt(2010, 9, 20, 21, 32, 49))


def test_datetime_to_ghdate():
    eq_(datetime_to_ghdate(dt(2011, 5, 22, 0, 24, 15)),
        '2011/05/22 00:24:15 -0700')

    eq_(datetime_to_ghdate(dt(2009, 4, 18, 20, 4, 9)),
        '2009/04/18 20:04:09 -0700')
    #eq_(datetime_to_ghdate(dt(2009, 11, 13, 4, 15, 17)),
    #    '2009/11/13 04:15:17 -0800')
    #eq_(datetime_to_ghdate(dt(2009, 11, 13, 4, 16, 20)),
    #    '2009/11/13 04:16:20 -0800')
    eq_(datetime_to_ghdate(dt(2010, 4, 18, 0, 24, 29)),
        '2010/04/18 00:24:29 -0700')
    eq_(datetime_to_ghdate(dt(2010, 5, 18, 13, 10, 36)),
        '2010/05/18 13:10:36 -0700')
    eq_(datetime_to_ghdate(dt(2010, 5, 26, 5, 59, 37)),
        '2010/05/26 05:59:37 -0700')
    eq_(datetime_to_ghdate(dt(2010, 5, 27, 0, 8, 41)),
        '2010/05/27 00:08:41 -0700')
    eq_(datetime_to_ghdate(dt(2010, 6, 20, 13, 13, 37)),
        '2010/06/20 13:13:37 -0700')
    eq_(datetime_to_ghdate(dt(2010, 7, 28, 19, 56, 51)),
        '2010/07/28 19:56:51 -0700')

    eq_(datetime_to_ghdate(dt(2010, 9, 21, 4, 32, 49)),