# Path: alertaclient/utils.py
# class DateTime:
#     @staticmethod
#     def parse(date_str):
#         if not isinstance(date_str, str):
#             return
#         try:
#             return datetime.datetime.strptime(date_str, '%Y-%m-%dT%H:%M:%S.%fZ')
#         except Exception:
#             raise ValueError('dates must be ISO 8601 date format YYYY-MM-DDThh:mm:ss.sssZ')
# 
#     @staticmethod
#     def iso8601(dt):
#         return dt.replace(microsecond=0).strftime('%Y-%m-%dT%H:%M:%S') + '.%03dZ' % (dt.microsecond // 1000)
# 
#     @staticmethod
#     def localtime(dt, timezone=None, fmt='%Y/%m/%d %H:%M:%S'):
#         tz = pytz.timezone(timezone)
#         try:
#             return dt.replace(tzinfo=pytz.UTC).astimezone(tz).strftime(fmt)
#         except AttributeError:
#             return


from datetime import datetime, timedelta
from alertaclient.utils import DateTime
        return Blackout(
            id=json.get('id'),
            environment=json.get('environment'),
            service=json.get('service', list()),
            resource=json.get('resource', None),
            event=json.get('event', None),
            group=json.get('group', None),
            tags=json.get('tags', list()),
            origin=json.get('origin', None),
            customer=json.get('customer', None),
            start_time=DateTime.parse(json.get('startTime')),
            end_time=DateTime.parse(json.get('endTime')),
            duration=json.get('duration', None),
            user=json.get('user', None),
            create_time=DateTime.parse(json.get('createTime')),
            text=json.get('text', None)
        )

    def tabular(self, timezone=None):
        return {
            'id': self.id,
            'priority': self.priority,
            'environment': self.environment,
            'service': ','.join(self.service),
            'resource': self.resource,
            'event': self.event,
            'group': self.group,
            'tags': ','.join(self.tags),
            'origin': self.origin,
            'customer': self.customer,

# Path: alertaclient/utils.py
# class DateTime:
#     @staticmethod
#     def parse(date_str):
#         if not isinstance(date_str, str):
#             return
#         try:
#             return datetime.datetime.strptime(date_str, '%Y-%m-%dT%H:%M:%S.%fZ')
#         except Exception:
#             raise ValueError('dates must be ISO 8601 date format YYYY-MM-DDThh:mm:ss.sssZ')
# 
#     @staticmethod
#     def iso8601(dt):
#         return dt.replace(microsecond=0).strftime('%Y-%m-%dT%H:%M:%S') + '.%03dZ' % (dt.microsecond // 1000)
# 
#     @staticmethod
#     def localtime(dt, timezone=None, fmt='%Y/%m/%d %H:%M:%S'):
#         tz = pytz.timezone(timezone)
#         try:
#             return dt.replace(tzinfo=pytz.UTC).astimezone(tz).strftime(fmt)
#         except AttributeError:
#             return


# Path: alertaclient/models/blackout.py
from datetime import datetime, timedelta
from alertaclient.utils import DateTime

        return Blackout(
            id=json.get('id'),
            environment=json.get('environment'),
            service=json.get('service', list()),
            resource=json.get('resource', None),
            event=json.get('event', None),
            group=json.get('group', None),
            tags=json.get('tags', list()),
            origin=json.get('origin', None),
            customer=json.get('customer', None),
            start_time=DateTime.parse(json.get('startTime')),
            end_time=DateTime.parse(json.get('endTime')),
            duration=json.get('duration', None),
            user=json.get('user', None),
            create_time=DateTime.parse(json.get('createTime')),
            text=json.get('text', None)
        )

    def tabular(self, timezone=None):
        return {
            'id': self.id,
            'priority': self.priority,
            'environment': self.environment,
            'service': ','.join(self.service),
            'resource': self.resource,
            'event': self.event,
            'group': self.group,
            'tags': ','.join(self.tags),
            'origin': self.origin,
            'customer': self.customer,

            'startTime': DateTime.localtime(self.start_time, timezone),