def get_datetime(metadata):
    """Return the datetime object associated with the metadata.

    This exists mostly as a compatilbity layer for different versions of
    pyexiv2--later ones moved it into a .value attribute.

    """
    return getattr(
        metadata['Exif.Image.DateTime'],
        'value',
        metadata['Exif.Image.DateTime']
    )