# 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
                   mappings=None, idMapping=None,
                   additionalFields={}):
    if data_type is None:
        raise ValueError("Must provide a data type")
    if mappings is None:
        mappings = {}

    base_properties = {
        "_timestamp": to_datetime(item["start_date"]),
        "dataType": data_type
    }

    doc = dict(base_properties.items() +
               additionalFields.items() +
               item.get("dimensions", {}).items() +
               special_fields.items())
    doc = apply_key_mapping(mappings, doc)

    def get_value_for_key(key):
        return unicode(doc.get(key, ""))

    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,

# 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

                   mappings=None, idMapping=None,
                   additionalFields={}):
    if data_type is None:
        raise ValueError("Must provide a data type")
    if mappings is None:
        mappings = {}

    base_properties = {
        "_timestamp": to_datetime(item["start_date"]),
        "dataType": data_type
    }

    doc = dict(base_properties.items() +
               additionalFields.items() +
               item.get("dimensions", {}).items() +
               special_fields.items())
    doc = apply_key_mapping(mappings, doc)

    def get_value_for_key(key):
        return unicode(doc.get(key, ""))

    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"]),