# Path: elastalert/util.py
# def dt_to_ts(dt):
#     if not isinstance(dt, datetime.datetime):
#         logging.warning('Expected datetime, got %s' % (type(dt)))
#         return dt
#     ts = dt.isoformat()
#     # Round microseconds to milliseconds
#     if dt.tzinfo is None:
#         # Implicitly convert local times to UTC
#         return ts + 'Z'
#     # isoformat() uses microsecond accuracy and timezone offsets
#     # but we should try to use millisecond accuracy and Z to indicate UTC
#     return ts.replace('000+00:00', 'Z').replace('+00:00', 'Z')
# 
# Path: elastalert/util.py
# def ts_to_dt(timestamp):
#     if isinstance(timestamp, datetime.datetime):
#         return timestamp
#     dt = dateutil.parser.parse(timestamp)
#     # Implicitly convert local timestamps to UTC
#     if dt.tzinfo is None:
#         dt = dt.replace(tzinfo=pytz.utc)
#     return dt


import datetime
import logging
import os
import mock
import pytest
import elastalert.elastalert
import elastalert.util
from elastalert.util import dt_to_ts
from elastalert.util import ts_to_dt
            ea = elastalert.elastalert.ElastAlerter(['--pin_rules'])
    ea.rules[0]['type'] = mock_ruletype()
    ea.rules[0]['alert'] = [mock_alert()]
    ea.writeback_es = mock_es_client()
    ea.writeback_es.search.return_value = {'hits': {'hits': []}, 'total': 0}
    ea.writeback_es.deprecated_search.return_value = {'hits': {'hits': []}}
    ea.writeback_es.index.return_value = {'_id': 'ABCD', 'created': True}
    ea.current_es = mock_es_client('', '')
    ea.thread_data.current_es = ea.current_es
    ea.thread_data.num_hits = 0
    ea.thread_data.num_dupes = 0
    return ea


@pytest.fixture
def ea_sixsix():
    rules = [{'es_host': '',
              'es_port': 14900,
              'name': 'anytest',
              'index': 'idx',
              'filter': [],
              'include': ['@timestamp'],
              'run_every': datetime.timedelta(seconds=1),
              'aggregation': datetime.timedelta(0),
              'realert': datetime.timedelta(0),
              'processed_hits': {},
              'timestamp_field': '@timestamp',
              'match_enhancements': [],
              'rule_file': 'blah.yaml',
              'max_query_size': 10000,

# Path: elastalert/util.py
# def dt_to_ts(dt):
#     if not isinstance(dt, datetime.datetime):
#         logging.warning('Expected datetime, got %s' % (type(dt)))
#         return dt
#     ts = dt.isoformat()
#     # Round microseconds to milliseconds
#     if dt.tzinfo is None:
#         # Implicitly convert local times to UTC
#         return ts + 'Z'
#     # isoformat() uses microsecond accuracy and timezone offsets
#     # but we should try to use millisecond accuracy and Z to indicate UTC
#     return ts.replace('000+00:00', 'Z').replace('+00:00', 'Z')
# 
# Path: elastalert/util.py
# def ts_to_dt(timestamp):
#     if isinstance(timestamp, datetime.datetime):
#         return timestamp
#     dt = dateutil.parser.parse(timestamp)
#     # Implicitly convert local timestamps to UTC
#     if dt.tzinfo is None:
#         dt = dt.replace(tzinfo=pytz.utc)
#     return dt


# Path: tests/conftest.py
import datetime
import logging
import os
import mock
import pytest
import elastalert.elastalert
import elastalert.util
from elastalert.util import dt_to_ts
from elastalert.util import ts_to_dt

            ea = elastalert.elastalert.ElastAlerter(['--pin_rules'])
    ea.rules[0]['type'] = mock_ruletype()
    ea.rules[0]['alert'] = [mock_alert()]
    ea.writeback_es = mock_es_client()
    ea.writeback_es.search.return_value = {'hits': {'hits': []}, 'total': 0}
    ea.writeback_es.deprecated_search.return_value = {'hits': {'hits': []}}
    ea.writeback_es.index.return_value = {'_id': 'ABCD', 'created': True}
    ea.current_es = mock_es_client('', '')
    ea.thread_data.current_es = ea.current_es
    ea.thread_data.num_hits = 0
    ea.thread_data.num_dupes = 0
    return ea


@pytest.fixture
def ea_sixsix():
    rules = [{'es_host': '',
              'es_port': 14900,
              'name': 'anytest',
              'index': 'idx',
              'filter': [],
              'include': ['@timestamp'],
              'run_every': datetime.timedelta(seconds=1),
              'aggregation': datetime.timedelta(0),
              'realert': datetime.timedelta(0),
              'processed_hits': {},
              'timestamp_field': '@timestamp',
              'match_enhancements': [],
              'rule_file': 'blah.yaml',
              'max_query_size': 10000,

              'ts_to_dt': ts_to_dt,