# Path: github2/core.py
# LOGGER = logging.getLogger('github2.core')
# PY3K = sys.version_info[0] == 3
# PY27 = sys.version_info[:2] >= (2, 7)
# GITHUB_DATE_FORMAT = "%Y/%m/%d %H:%M:%S %z"
# COMMIT_DATE_FORMAT = "%Y-%m-%dT%H:%M:%S"
# GITHUB_TZ = tz.gettz("America/Los_Angeles")
# NAIVE = True
# def string_to_datetime(string):
# def _handle_naive_datetimes(f):
#     def wrapper(datetime_):
# def datetime_to_ghdate(datetime_):
# def datetime_to_commitdate(datetime_):
# def datetime_to_isodate(datetime_):
# def requires_auth(f):
#     def wrapper(self, *args, **kwargs):
# def enhanced_by_auth(f):
#     def __init__(self, request):
#     def make_request(self, command, *args, **kwargs):
#     def get_value(self, *args, **kwargs):
#     def get_values(self, *args, **kwargs):
# def doc_generator(docstring, attributes):
#     def bullet(title, text):
#     def __init__(self, help):
#     def to_python(self, value):
#     def __init__(self, *args, **kwargs):
#     def to_python(self, value):
#     def from_python(self, value):
#     def __new__(cls, name, bases, attrs):
#         def _contribute_method(name, func):
#         def constructor(self, **kwargs):
#         def iterate(self):
#     def __getitem__(self, key):
#     def __setitem__(self, key, value):
# def repr_string(string):
# class AuthError(Exception):
# class GithubCommand(object):
# class Attribute(object):
# class DateAttribute(Attribute):
# class BaseDataType(type):
# class BaseData(BaseDataType('BaseData', (object, ), {})):
# 
# 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 dateutil.tz import tzutc
from nose.tools import eq_
from github2 import core
from github2.core import (datetime_to_ghdate, datetime_to_commitdate,
                          datetime_to_isodate, string_to_datetime)
        dt_utz(2011, 5, 22, 7, 24, 15))
    eq_(string_to_datetime('2011-04-09T10:07:30-07:00'),
        dt_utz(2011, 4, 9, 17, 7, 30))
    eq_(string_to_datetime('2011-02-19T07:16:11-08:00'),
        dt_utz(2011, 2, 19, 15, 16, 11))
    eq_(string_to_datetime('2010-12-21T12:34:27-08:00'),
        dt_utz(2010, 12, 21, 20, 34, 27))
    eq_(string_to_datetime('2011-04-09T10:20:05-07:00'),
        dt_utz(2011, 4, 9, 17, 20, 5))
    eq_(string_to_datetime('2011-04-09T10:05:58-07:00'),
        dt_utz(2011, 4, 9, 17, 5, 58))
    eq_(string_to_datetime('2011-04-09T09:53:00-07:00'),
        dt_utz(2011, 4, 9, 16, 53, 0))
    eq_(string_to_datetime('2011-04-09T10:00:21-07:00'),
        dt_utz(2011, 4, 9, 17, 0, 21))
    eq_(string_to_datetime('2010-12-16T15:10:59-08:00'),
        dt_utz(2010, 12, 16, 23, 10, 59))
    eq_(string_to_datetime('2011-04-09T09:53:00-07:00'),
        dt_utz(2011, 4, 9, 16, 53, 0))
    eq_(string_to_datetime('2011-04-09T09:53:00-07:00'),
        dt_utz(2011, 4, 9, 16, 53, 0))


def test_datetime_to_commitdate():
    eq_(datetime_to_commitdate(dt_utz(2011, 5, 22, 7, 24, 15)),
        '2011-05-22T00:24:15-07:00')
    eq_(datetime_to_commitdate(dt_utz(2011, 4, 9, 17, 7, 30)),
        '2011-04-09T10:07:30-07:00')
    eq_(datetime_to_commitdate(dt_utz(2011, 2, 19, 15, 16, 11)),
        '2011-02-19T07:16:11-08:00')

# Path: github2/core.py
# LOGGER = logging.getLogger('github2.core')
# PY3K = sys.version_info[0] == 3
# PY27 = sys.version_info[:2] >= (2, 7)
# GITHUB_DATE_FORMAT = "%Y/%m/%d %H:%M:%S %z"
# COMMIT_DATE_FORMAT = "%Y-%m-%dT%H:%M:%S"
# GITHUB_TZ = tz.gettz("America/Los_Angeles")
# NAIVE = True
# def string_to_datetime(string):
# def _handle_naive_datetimes(f):
#     def wrapper(datetime_):
# def datetime_to_ghdate(datetime_):
# def datetime_to_commitdate(datetime_):
# def datetime_to_isodate(datetime_):
# def requires_auth(f):
#     def wrapper(self, *args, **kwargs):
# def enhanced_by_auth(f):
#     def __init__(self, request):
#     def make_request(self, command, *args, **kwargs):
#     def get_value(self, *args, **kwargs):
#     def get_values(self, *args, **kwargs):
# def doc_generator(docstring, attributes):
#     def bullet(title, text):
#     def __init__(self, help):
#     def to_python(self, value):
#     def __init__(self, *args, **kwargs):
#     def to_python(self, value):
#     def from_python(self, value):
#     def __new__(cls, name, bases, attrs):
#         def _contribute_method(name, func):
#         def constructor(self, **kwargs):
#         def iterate(self):
#     def __getitem__(self, key):
#     def __setitem__(self, key, value):
# def repr_string(string):
# class AuthError(Exception):
# class GithubCommand(object):
# class Attribute(object):
# class DateAttribute(Attribute):
# class BaseDataType(type):
# class BaseData(BaseDataType('BaseData', (object, ), {})):
# 
# 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_tz_aware_date_handling.py
from datetime import datetime as dt
from dateutil.tz import tzutc
from nose.tools import eq_
from github2 import core
from github2.core import (datetime_to_ghdate, datetime_to_commitdate,
                          datetime_to_isodate, string_to_datetime)

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


def test_datetime_to_commitdate():
    eq_(datetime_to_commitdate(dt_utz(2011, 5, 22, 7, 24, 15)),
        '2011-05-22T00:24:15-07:00')
    eq_(datetime_to_commitdate(dt_utz(2011, 4, 9, 17, 7, 30)),
        '2011-04-09T10:07:30-07:00')
    eq_(datetime_to_commitdate(dt_utz(2011, 2, 19, 15, 16, 11)),
        '2011-02-19T07:16:11-08:00')

    eq_(datetime_to_commitdate(dt_utz(2010, 12, 21, 20, 34, 27)),