code: def date_to_integer(date):
      
      if pd and isinstance(date, pd.Timestamp):
          try:
              date = date.to_datetime64()
          except:
              date = date.to_datetime()
  
      if isinstance(date, np.datetime64):
          return date.astype('datetime64[ms]').astype(float)
      elif isinstance(date, cftime_types):
          return cftime_to_timestamp(date, 'ms')
  
      if hasattr(date, 'timetuple'):
          dt_int = calendar.timegm(date.timetuple())*1000
      else:
          raise ValueError('Datetime type not recognized')
      return dt_int
docs: Converts support date types to milliseconds since epoch
  
      Attempts highest precision conversion of different datetime
      formats to milliseconds since the epoch (1970-01-01 00:00:00).
      If datetime is a cftime with a non-standard calendar the
      caveats described in hv.core.util.cftime_to_timestamp apply.
  
      Args:
          date: Date- or datetime-like object
  
      Returns:
          Milliseconds since 1970-01-01 00:00:00