Return a python datetime object

    xldate: float
        The xl number.

    datemode: int
        0: 1900-based, 1: 1904-based. See xlrd documentation.
162169
def fromxldate(xldate, datemode=1):
    

    t = xlrd.xldate_as_tuple(xldate, datemode)
    return datetime.datetime(*t)
787545
def time_from_number(self, value):
        
        if not isinstance(value, numbers.Real):
            return None
        delta = datetime.timedelta(days=value)
        minutes, second = divmod(delta.seconds, 60)
        hour, minute = divmod(minutes, 60)
        return datetime.time(hour, minute, second)
309408
def from_date(cls, date):
        
        try:
            date = date.date()
        except AttributeError:
            pass
        return cls(date.year, date.month)
1373214
function getDateObject(datetime) {
  var t = datetime instanceof Date ? datetime : new Date(datetime);
  if (!t.getDate()) {
    t = new Date();
  }
  return t;
}
399668
def string_to_datetime(self, obj):
        
        if isinstance(obj, six.string_types) and len(obj) == 19:
            try:
                return datetime.strptime(obj, "%Y-%m-%dT%H:%M:%S")
            except ValueError:
                pass
        if isinstance(obj, six.string_types) and len(obj) > 19:
            try:
                return datetime.strptime(obj, "%Y-%m-%dT%H:%M:%S.%f")
            except ValueError:
                pass
        if isinstance(obj, six.string_types) and len(obj) == 10:
            try:
                return datetime.strptime(obj, "%Y-%m-%d")
            except ValueError:
                pass
        return obj
460741
def __date_format(self, x):
        

        if x < 1: x = 1

        span = self.axes.xaxis.get_view_interval()
        tmin = max(1.0, span[0])
        tmax = max(2.0, span[1])
        tmin = time.mktime(dates.num2date(tmin).timetuple())
        tmax = time.mktime(dates.num2date(tmax).timetuple())
        nhours = (tmax - tmin)/3600.0
        fmt = "%m/%d"
        if nhours < 0.1:
            fmt = "%H:%M\n%Ssec"
        elif nhours < 4:
            fmt = "%m/%d\n%H:%M"
        elif nhours < 24*8:
            fmt = "%m/%d\n%H:%M"
        try:
            return time.strftime(fmt, dates.num2date(x).timetuple())
        except:
            return "?"
61812
def to_ts(date: datetime.date) -> float:
    
    return datetime.datetime(
        date.year, date.month, date.day,
        tzinfo=datetime.timezone.utc).timestamp()
1031986
def to_date(ts: float) -> datetime.date:
    
    return datetime.datetime.fromtimestamp(
        ts, tz=datetime.timezone.utc).date()
1132450
def datetime_to_http_date(the_datetime):
    
    timeval = calendar.timegm(the_datetime.utctimetuple())
    return formatdate(timeval=timeval,
                      localtime=False,
                      usegmt=True)
555898
def datetime(self):
        
        date_string = '%s %s %s' % (self._day,
                                    self._date,
                                    self._year)
        return datetime.strptime(date_string, '%a %B %d %Y')
546725
def excel_datetime(timestamp, epoch=None):
    
    if epoch is None:
        epoch = datetime.datetime.fromordinal(693594)
    return epoch + datetime.timedelta(timestamp)
937085
def date(self, field=None, val=None):
        
        return self.datetime(field=field, val=val).date()
1084006
def _x_format(self):
        """"""

        def date_to_str(x):
            t = seconds_to_time(x)
            return self.x_value_formatter(t)

        return date_to_str
768209
def _converter(self, value):
        """"""
        if not isinstance(value, datetime.date):
            raise TypeError('{0} is not valid date'.format(value))
        return value
618103
def load_datetime(value, dt_format):
    
    if dt_format.endswith('%z'):
        dt_format = dt_format[:-2]
        offset = value[-5:]
        value = value[:-5]
        if offset != offset.replace(':', ''):
            # strip : from HHMM if needed (isoformat() adds it between HH and MM)
            offset = '+' + offset.replace(':', '')
            value = value[:-1]
        return OffsetTime(offset).localize(datetime.strptime(value, dt_format))

    return datetime.strptime(value, dt_format)
1191268
def as_datetime(self):
        '''
        '''
        year = int(self.year)
        month = int(self.month) if self.month else 1
        day = int(self.day) if self.day else 1
        hour = int(self.hour) if self.hour else 0
        minute = int(self.minute) if self.minute else 0
        second = int(self.second) if self.second else 0
        microsecond = int(self.microsecond) if self.microsecond else 0
        return datetime.datetime(year, month, day, hour, minute, second, microsecond)
808063
def safe_date(self, x):
        

        t = x[self.col_name]
        if np.isnan(t):
            return t

        elif np.isposinf(t):
            t = sys.maxsize

        elif np.isneginf(t):
            t = -sys.maxsize

        tmp = time.localtime(float(t) / 1e9)
        return time.strftime(self.date_format, tmp)