def METHOD_NAME(device):
    device = defaultdict(str, device)
    date = device['driver-date']
    if type(date) is int:
        # If type is int it is number of nanoseconds since epoch otherwise it
        # is string in form YYYY-MM-DD and we don't have to do anything
        dt = datetime.datetime.fromtimestamp(date // 10**9, tz=tz.tzutc())
        return {
            'device_id': int(device['id']['device-id']),
            'driver_date': dt.date().isoformat(),
            'driver_name': device['driver-name'],
            'driver_version': device['driver-version'],
            'vendor_id': int(device['id']['vendor-id']),
        }
    else:
        return {
            'device_id': int(device['address']['data']['device-id']),
            'driver_date': date,
            'driver_name': device['driver-name'],
            'driver_version': device['driver-version'],
            'vendor_id': int(device['address']['data']['vendor-id']),
        }