# Path: moira/graphite/attime.py
# def parseATTime(s, tzinfo=None):
#     if tzinfo is None:
#         tzinfo = pytz.utc
#     s = s.strip().lower().replace('_', '').replace(',', '').replace(' ', '')
#     if s.isdigit():
#         if len(s) == 8 and int(s[:4]) > 1900 and int(
#                 s[4:6]) < 13 and int(s[6:]) < 32:
#             pass  # Fall back because its not a timestamp, its YYYYMMDD form
#         else:
#             return datetime.fromtimestamp(int(s), tzinfo)
#     elif ':' in s and len(s) == 13:
#         return tzinfo.localize(datetime.strptime(s, '%H:%M%Y%m%d'), daylight)
#     if '+' in s:
#         ref, offset = s.split('+', 1)
#         offset = '+' + offset
#     elif '-' in s:
#         ref, offset = s.split('-', 1)
#         offset = '-' + offset
#     else:
#         ref, offset = s, ''
#     return (
#         parseTimeReference(ref) +
#         parseTimeOffset(offset)).astimezone(tzinfo)


from moira.graphite.util import epoch
from moira.graphite.attime import parseATTime
from twisted.internet import defer
"""Copyright 2008 Orbitz WorldWide

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License."""


db = None


def createRequestContext(fromTime, endTime, allowRealTimeAlerting):
    return {'startTime': parseATTime(fromTime),

# Path: moira/graphite/attime.py
# def parseATTime(s, tzinfo=None):
#     if tzinfo is None:
#         tzinfo = pytz.utc
#     s = s.strip().lower().replace('_', '').replace(',', '').replace(' ', '')
#     if s.isdigit():
#         if len(s) == 8 and int(s[:4]) > 1900 and int(
#                 s[4:6]) < 13 and int(s[6:]) < 32:
#             pass  # Fall back because its not a timestamp, its YYYYMMDD form
#         else:
#             return datetime.fromtimestamp(int(s), tzinfo)
#     elif ':' in s and len(s) == 13:
#         return tzinfo.localize(datetime.strptime(s, '%H:%M%Y%m%d'), daylight)
#     if '+' in s:
#         ref, offset = s.split('+', 1)
#         offset = '+' + offset
#     elif '-' in s:
#         ref, offset = s.split('-', 1)
#         offset = '-' + offset
#     else:
#         ref, offset = s, ''
#     return (
#         parseTimeReference(ref) +
#         parseTimeOffset(offset)).astimezone(tzinfo)


# Path: moira/graphite/datalib.py
from moira.graphite.util import epoch
from moira.graphite.attime import parseATTime
from twisted.internet import defer

"""Copyright 2008 Orbitz WorldWide

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License."""


db = None


def createRequestContext(fromTime, endTime, allowRealTimeAlerting):
    return {'startTime': parseATTime(fromTime),

            'endTime': parseATTime(endTime),