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