code: def test_datefield(tmpdir, driver, field_type):
      """
      Test date, time, datetime field types.
      """
  
      def _validate(val, val_exp, field_type, driver):
          if field_type == "date":
              return val == val_exp.isoformat()
  
          elif field_type == "datetime":
              # some drivers do not support timezones. In this case, Fiona converts datetime fields with a timezone other
              # than UTC to UTC. Thus, both the datetime read by Fiona, as well as expected value are first converted to
              # UTC before compared.
  
              # Milliseconds
              if _driver_supports_milliseconds(driver):
                  y, m, d, hh, mm, ss, ms, tz = parse_datetime(val)
                  if tz is not None:
                      tz = TZ(tz)
                  val_d = datetime.datetime(y, m, d, hh, mm, ss, ms, tz)
                  return compare_datetimes_utc(val_d, val_exp)
              else:
                  # No Milliseconds
                  y, m, d, hh, mm, ss, ms, tz = parse_datetime(val)
                  if tz is not None:
                      tz = TZ(tz)
                  val_d = datetime.datetime(y, m, d, hh, mm, ss, ms, tz)
                  return compare_datetimes_utc(
                      val_d, val_exp.replace(microsecond=0)
                  )
  
          elif field_type == "time":
              # some drivers do not support timezones. In this case, Fiona converts datetime fields with a timezone other
              # than UTC to UTC. Thus, both the time read by Fiona, as well as expected value are first converted to UTC
              # before compared.
  
              # Milliseconds
              if _driver_supports_milliseconds(driver):
                  y, m, d, hh, mm, ss, ms, tz = parse_time(val)
                  if tz is not None:
                      tz = TZ(tz)
                  val_d = datetime.time(hh, mm, ss, ms, tz)
                  return compare_times_utc(val_d, val_exp)
              else:
                  # No Milliseconds
                  y, m, d, hh, mm, ss, ms, tz = parse_time(val)
                  if tz is not None:
                      tz = TZ(tz)
                  val_d = datetime.time(hh, mm, ss, ms, tz)
                  return compare_times_utc(
                      val_d, val_exp.replace(microsecond=0)
                  )
          return False
  
      schema = get_schema(driver, field_type)
      path = str(tmpdir.join(get_temp_filename(driver)))
      values_in, values_exp = zip(
          *generate_testdata(field_type, driver)
      )
      records = get_records(driver, values_in)
  
      with fiona.open(path, "w", driver=driver, schema=schema) as c:
          c.writerecords(records)
  
      with fiona.open(path, "r") as c:
          assert (
              get_schema_field(driver, c.schema) == field_type
          ), f"Returned field type is {get_schema_field(driver, c.schema)}, expected {field_type}"
          items = [get_field(driver, f) for f in c]
          assert len(items) == len(values_in)
          for val, val_exp in zip(items, values_exp):
              assert _validate(
                  val, val_exp, field_type, driver
              ), f"{val} does not match {val_exp.isoformat()}"
  
imports: import fiona
  from fiona._env import get_gdal_version_num, calc_gdal_version_num
  import pytest
  from fiona.errors import DriverSupportError
  from fiona.rfc3339 import parse_time, parse_datetime
  from .conftest import get_temp_filename
  from fiona.env import GDALVersion
  from fiona.model import Feature
  import datetime
  from fiona.drvsupport import supported_drivers, driver_mode_mingdal, _driver_converts_field_type_silently_to_str, _driver_supports_field, _driver_converts_to_str, _driver_supports_timezones, _driver_supports_milliseconds, _driver_supports_mode
  import pytz
  from pytz import timezone
label_desc: Use image node_id 14 for calling a global function with example usage: test_datefield(tmpdir, driver, field_type) and returns: False, unknown, compare_datetimes_utc, compare_datetimes_utc, compare_times_utc, compare_times_utc