# Path: performanceplatform/utils/datetimeutil.py
# def to_datetime(a_date):
#     if type(a_date) == datetime:
#         return a_date.replace(tzinfo=pytz.UTC)
#     return datetime.combine(a_date, time(0)).replace(tzinfo=pytz.UTC)
# 
# def to_utc(a_datetime):
#     return a_datetime.astimezone(pytz.UTC)


from performanceplatform.utils.datetimeutil \
    import to_datetime, to_utc
    from performanceplatform.collector.ga.plugins import load_plugins
import logging
import base64
import re
    if idMapping is not None:
        if not isinstance(idMapping, list):
            idMapping = [idMapping]

        values_for_id = map(get_value_for_key, idMapping)
        string_for_id = "".join(values_for_id)
    else:
        string_for_id = get_string_for_data_id(
            data_type,
            to_datetime(item["start_date"]),
            doc.get('timeSpan', None),
            item.get('dimensions', {}).values())
    (_id, human_id) = value_id(string_for_id)

    doc['humanId'] = human_id
    doc['_id'] = _id

    return doc


def get_string_for_data_id(data_type, timestamp, period, dimension_values):
    # `dimension_values` may be non-string python types and need to be coerced.
    values = map(unicode, dimension_values)
    slugs = [data_type, _format(timestamp), period] + values
    slugs = [value for value in slugs
             if value is not None]
    return "_".join(slugs)


def _format(timestamp):

# Path: performanceplatform/utils/datetimeutil.py
# def to_datetime(a_date):
#     if type(a_date) == datetime:
#         return a_date.replace(tzinfo=pytz.UTC)
#     return datetime.combine(a_date, time(0)).replace(tzinfo=pytz.UTC)
# 
# def to_utc(a_datetime):
#     return a_datetime.astimezone(pytz.UTC)


# Path: performanceplatform/utils/data_parser.py
from performanceplatform.utils.datetimeutil \
    import to_datetime, to_utc
    from performanceplatform.collector.ga.plugins import load_plugins
import logging
import base64
import re

    if idMapping is not None:
        if not isinstance(idMapping, list):
            idMapping = [idMapping]

        values_for_id = map(get_value_for_key, idMapping)
        string_for_id = "".join(values_for_id)
    else:
        string_for_id = get_string_for_data_id(
            data_type,
            to_datetime(item["start_date"]),
            doc.get('timeSpan', None),
            item.get('dimensions', {}).values())
    (_id, human_id) = value_id(string_for_id)

    doc['humanId'] = human_id
    doc['_id'] = _id

    return doc


def get_string_for_data_id(data_type, timestamp, period, dimension_values):
    # `dimension_values` may be non-string python types and need to be coerced.
    values = map(unicode, dimension_values)
    slugs = [data_type, _format(timestamp), period] + values
    slugs = [value for value in slugs
             if value is not None]
    return "_".join(slugs)


def _format(timestamp):

    return to_utc(timestamp).strftime("%Y%m%d%H%M%S")