@@ -164,6 +164,7 @@ def tzname(self, dt):
164
164
def dst (self , dt ):
165
165
return datetime .timedelta (0 )
166
166
167
+
167
168
UTC = _UTC ()
168
169
169
170
@@ -327,8 +328,8 @@ def datestr2num(d, default=None):
327
328
d : string or sequence of strings
328
329
The dates to convert.
329
330
330
- default : datetime instance
331
- The default date to use when fields are missing in `d` .
331
+ default : datetime instance, optional
332
+ The default date to use when fields are missing in *d* .
332
333
"""
333
334
if isinstance (d , six .string_types ):
334
335
dt = dateutil .parser .parse (d , default = default )
@@ -344,14 +345,23 @@ def datestr2num(d, default=None):
344
345
345
346
def date2num (d ):
346
347
"""
347
- *d* is either a :class:`datetime` instance or a sequence of datetimes.
348
+ Converts datetime objects to Matplotlib dates.
349
+
350
+ Parameters
351
+ ----------
352
+ d: :class:`datetime` or sequence of :class:`datetime`
348
353
349
- Return value is a floating point number (or sequence of floats)
350
- which gives the number of days (fraction part represents hours,
351
- minutes, seconds) since 0001-01-01 00:00:00 UTC, *plus* *one*.
352
- The addition of one here is a historical artifact. Also, note
353
- that the Gregorian calendar is assumed; this is not universal
354
- practice. For details, see the module docstring.
354
+ Returns
355
+ -------
356
+ float or sequence of floats
357
+ Number of days (fraction part represents hours, minutes, seconds)
358
+ since 0001-01-01 00:00:00 UTC, plus one.
359
+
360
+ Notes
361
+ -----
362
+ The addition of one here is a historical artifact. Also, note that the
363
+ Gregorian calendar is assumed; this is not universal practice.
364
+ For details see the module docstring.
355
365
"""
356
366
if not cbook .iterable (d ):
357
367
return _to_ordinalf (d )
@@ -365,6 +375,16 @@ def date2num(d):
365
375
def julian2num (j ):
366
376
"""
367
377
Convert a Julian date (or sequence) to a matplotlib date (or sequence).
378
+
379
+ Parameters
380
+ ----------
381
+ k: float or sequence of floats
382
+ Julian date(s)
383
+
384
+ Returns
385
+ -------
386
+ float or sequency of floats
387
+ Matplotlib date(s)
368
388
"""
369
389
if cbook .iterable (j ):
370
390
j = np .asarray (j )
@@ -373,7 +393,17 @@ def julian2num(j):
373
393
374
394
def num2julian (n ):
375
395
"""
376
- Convert a matplotlib date (or sequence) to a Julian date (or sequence).
396
+ Convert a Matplotlib date (or sequence) to a Julian date (or sequence).
397
+
398
+ Parameters
399
+ ----------
400
+ n: float or sequence of floats
401
+ Matplotlib date(s)
402
+
403
+ Returns
404
+ -------
405
+ float or sequency of floats
406
+ Julian date(s)
377
407
"""
378
408
if cbook .iterable (n ):
379
409
n = np .asarray (n )
@@ -382,18 +412,27 @@ def num2julian(n):
382
412
383
413
def num2date (x , tz = None ):
384
414
"""
385
- *x* is a float value which gives the number of days
386
- (fraction part represents hours, minutes, seconds) since
387
- 0001-01-01 00:00:00 UTC *plus* *one*.
388
- The addition of one here is a historical artifact. Also, note
389
- that the Gregorian calendar is assumed; this is not universal
390
- practice. For details, see the module docstring.
415
+ Parameters
416
+ ----------
417
+ x: float
418
+ Number of days (fraction part represents hours, minutes, seconds)
419
+ since 0001-01-01 00:00:00 UTC, plus one.
420
+ tz: string, optional
421
+ Timezone of *x* (defaults to rcparams TZ value).
391
422
392
- Return value is a :class:`datetime` instance in timezone *tz* (default to
393
- rcparams TZ value).
423
+ Returns
424
+ -------
425
+ :class:`datetime` or sequence of :class:`datetime`
426
+ Dates are returned in timezone *tz*
394
427
395
428
If *x* is a sequence, a sequence of :class:`datetime` objects will
396
429
be returned.
430
+
431
+ Notes
432
+ -----
433
+ The addition of one here is a historical artifact. Also, note that the
434
+ Gregorian calendar is assumed; this is not universal practice.
435
+ For details, see the module docstring.
397
436
"""
398
437
if tz is None :
399
438
tz = _get_rc_timezone ()
0 commit comments