MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / datestr2num

Function datestr2num

lib/matplotlib/dates.py:377–400  ·  view source on GitHub ↗

Convert a date string to a datenum using `dateutil.parser.parse`. Parameters ---------- d : str or sequence of str The dates to convert. default : datetime.datetime, optional The default date to use when fields are missing in *d*.

(d, default=None)

Source from the content-addressed store, hash-verified

375
376
377def datestr2num(d, default=None):
378 """
379 Convert a date string to a datenum using `dateutil.parser.parse`.
380
381 Parameters
382 ----------
383 d : str or sequence of str
384 The dates to convert.
385
386 default : datetime.datetime, optional
387 The default date to use when fields are missing in *d*.
388 """
389 if isinstance(d, str):
390 dt = dateutil.parser.parse(d, default=default)
391 return date2num(dt)
392 else:
393 if default is not None:
394 d = [date2num(dateutil.parser.parse(s, default=default))
395 for s in d]
396 return np.asarray(d)
397 d = np.asarray(d)
398 if not d.size:
399 return d
400 return date2num(_dateutil_parser_parse_np_vectorized(d))
401
402
403def date2num(d):

Callers

nothing calls this directly

Calls 2

date2numFunction · 0.85
parseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…