# Path: doorman/compat.py
# PY2 = int(sys.version[0]) == 2
# def with_metaclass(meta, *bases):
#         def __new__(cls, name, this_bases, d):
#     class metaclass(meta):


from datetime import datetime
from time import mktime
from doorman.compat import string_types
import json
# -*- coding: utf-8 -*-



class DJSONEncoder(json.JSONEncoder):
    def default(self, obj):
        if isinstance(obj, datetime):
            return {
                '__type__': '__datetime__',
                'epoch': int(mktime(obj.timetuple()))
            }
        else:
            return json.JSONEncoder.default(self, obj)


def djson_decoder(obj):
    if '__type__' in obj:
        if obj['__type__'] == '__datetime__':
            return datetime.fromtimestamp(obj['epoch'])
    return obj


# Encoder function
def djson_dumps(obj):
    return json.dumps(obj, cls=DJSONEncoder)


# Decoder function
def djson_loads(s):

# Path: doorman/compat.py
# PY2 = int(sys.version[0]) == 2
# def with_metaclass(meta, *bases):
#         def __new__(cls, name, this_bases, d):
#     class metaclass(meta):


# Path: doorman/celery_serializer.py
from datetime import datetime
from time import mktime
from doorman.compat import string_types
import json

# -*- coding: utf-8 -*-



class DJSONEncoder(json.JSONEncoder):
    def default(self, obj):
        if isinstance(obj, datetime):
            return {
                '__type__': '__datetime__',
                'epoch': int(mktime(obj.timetuple()))
            }
        else:
            return json.JSONEncoder.default(self, obj)


def djson_decoder(obj):
    if '__type__' in obj:
        if obj['__type__'] == '__datetime__':
            return datetime.fromtimestamp(obj['epoch'])
    return obj


# Encoder function
def djson_dumps(obj):
    return json.dumps(obj, cls=DJSONEncoder)


# Decoder function
def djson_loads(s):

    if not isinstance(s, string_types):