class_docstr: Validate and parse dates using the `dateutil` package.
docstr: Returns an integer corresponding to the number of milliseconds since
  epoch in the local timezone.
  
  If the `datetime.datetime` object has a `timezone` property set, this
  method will convert the object into UTC before returning a timestamp.
docstr_tok: ["Returns","an","integer","corresponding","to","the","number","of","milliseconds","since","epoch","in","the","local","timezone",".","If","the","`","datetime.datetime","`","object","has","a","`","timezone","`","property","set",",","this","method","will","convert","the","object","into","UTC","before","returning","a","timestamp","."]
code: def to_timestamp(self, obj):
      """Returns an integer corresponding to the number of milliseconds since
      epoch in the local timezone.
  
      If the `datetime.datetime` object has a `timezone` property set, this
      method will convert the object into UTC before returning a timestamp.
      """
      if obj is None:
          return obj
  
      if obj.__class__.__name__ == "date":
          # handle updating datetime with date object
          obj = datetime(obj.year, obj.month, obj.day)
  
      if isinstance(obj, Period):
          # extract the start of the Period
          obj = obj.to_timestamp()
  
      # time.mktime converts local time, calendar.timegm uses UTC
      converter = mktime
  
      # timetuple returns local time, utctimetuple returns UTC
      to_timetuple = "timetuple"
  
      if hasattr(obj, "tzinfo") and obj.tzinfo is not None:
          # Convert all timezone-aware datetimes into UTC. If a datetime with
          # a valid `tzinfo` object has been passed in, this will read
          # `tzinfo` and convert the datetime into UTC. If the datetime has no
          # `tzinfo` object, it is assumed to be in local time, and will not
          # be converted into UTC.
          obj = obj.astimezone(UTC)
          converter = timegm
          to_timetuple = "utctimetuple"
  
      if isinstance(obj, numpy.datetime64):
          if str(obj) == "NaT":
              return None
  
          # astype(datetime) returns an int or a long (in python 2)
          obj = obj.astype(datetime)
  
          if isinstance(obj, date) and not isinstance(obj, datetime):
              # Convert numpy "datetime64[D/W/M/Y]", as they are converted
              # into `datetime.date`.
              return int(
                  (converter(getattr(obj, to_timetuple)())) * 1000
              )
  
          if isinstance(obj, int):
              return round(obj / 1000000)
  
      if isinstance(
          obj, (int, float, numpy.integer, numpy.float64, numpy.float32)
      ):
          return _normalize_timestamp(obj)
  
      timetuple = getattr(obj, to_timetuple)()
  
      is_datetime_min = (
          timetuple.tm_year == 1
          and timetuple.tm_mon == 1
          and timetuple.tm_mday == 1
          and timetuple.tm_hour == 0
          and timetuple.tm_min == 0
          and timetuple.tm_sec == 0
      )
  
      if is_datetime_min:
          # Return beginning of epoch when datetime is datetime.min
          return 0
  
      if timetuple.tm_year < 1900:
          # Use calendar.timegm to do conversion between timetuple and
          # seconds timestamp
          converter = timegm
  
      # At this point, aware datetime objects are in UTC, and naive datetime
      # objects have not been modified. When the timestamp is serialized
      # using `to_format`, it will be in *local time* - Pybind will
      # automatically localize any conversion to `datetime.datetime`
      # from C++ to Python.
      seconds_timestamp = (
          converter(timetuple) + obj.microsecond / 1000000.0
      )
      ms_timestamp = int(seconds_timestamp * 1000)
      return ms_timestamp
  
file_path: perspective/python/perspective/perspective/table/_date_validator.py
imports: import numpy
  from calendar import timegm
  from datetime import date, datetime
  from dateutil.parser import parse
  from pytz import UTC
  from pandas import Period
  from re import search
  from time import mktime
  from .libpsppy import t_dtype
label_desc: Use image node_id 3 for calling the _PerspectiveDateValidator obj's underlying member method code with example usage: obj.to_timestamp(obj) and returns: ms_timestamp, obj, _normalize_timestamp, int, None, int, round