code: def date2num(dt, tz=None):
      """
      Convert :mod:`datetime` to the Gregorian date as UTC float days,
      preserving hours, minutes, seconds and microseconds.  Return value
      is a :func:`float`.
      """
      if tz is not None:
          dt = tz.localize(dt)
  
      if hasattr(dt, "tzinfo") and dt.tzinfo is not None:
          delta = dt.tzinfo.utcoffset(dt)
          if delta is not None:
              dt -= delta
  
      base = float(dt.toordinal())
      if hasattr(dt, "hour"):
          # base += (dt.hour / HOURS_PER_DAY +
          #          dt.minute / MINUTES_PER_DAY +
          #          dt.second / SECONDS_PER_DAY +
          #          dt.microsecond / MUSECONDS_PER_DAY
          #         )
          base = math.fsum(
              (
                  base,
                  dt.hour / HOURS_PER_DAY,
                  dt.minute / MINUTES_PER_DAY,
                  dt.second / SECONDS_PER_DAY,
                  dt.microsecond / MUSECONDS_PER_DAY,
              )
          )
  
      return base
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import datetime
  import math
  import time
  from .py3 import string_types
label_desc: Use image node_id 6 for calling a global function with example usage: date2num(dt, tz) and returns: base