8000 some more notes regarding format codes doc · matplotlib/matplotlib@9b0f34b · GitHub
[go: up one dir, main page]

Skip to content

Commit 9b0f34b

Browse files
committed
some more notes regarding format codes doc
1 parent efeef9f commit 9b0f34b

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

lib/matplotlib/dates.py

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -623,41 +623,50 @@ def strftimedelta(td, fmt_str):
623623
Return a string representing a timedelta, controlled by an explicit
624624
format string.
625625
626-
The format codes are similar to the C standard format codes for formatting
627-
dates. All format codes that are reasonably transferable to timedelta are
628-
supported. Additionally, some extensions to the C standard are defined.
626+
The format codes are similar to the Python's datetime format codes from the
627+
:mod:`datetime` module (which are equivalent to the C standard format
628+
codes).
629629
630-
The following is a full list of the format codes that are supported.
630+
The following is a full list of the format codes that are supported by this
631+
function.
631632
632633
+-----------+---------------------------------------+---------------------+
633-
| Directive | Meaning | Example |
634+
| Code | Meaning | Example |
634635
+-----------+---------------------------------------+---------------------+
635-
| %d | Days | 0, 1, 2, ... |
636+
| %d | Days (*) | 0, 1, 2, ... |
636637
+-----------+---------------------------------------+---------------------+
637638
| %H | Hours as zero-padded decimal number | 00, 01, ..., 23 |
638639
+-----------+---------------------------------------+---------------------+
639640
| %M | Minutes as zero-padded decimal number | 00, 01, ..., 59 |
640641
+-----------+---------------------------------------+---------------------+
641642
| %S | Seconds as zero-padded decimal number | 00, 01, ..., 59 |
642643
+-----------+---------------------------------------+---------------------+
643-
| %-H | Hours as decimal number | 0, 1, ..., 23 |
644+
| %-H | Hours as decimal number (**) | 0, 1, ..., 23 |
644645
+-----------+---------------------------------------+---------------------+
645-
| %-M | Minutes as decimal number | 0, 1, ..., 59 |
646+
| %-M | Minutes as decimal number (**) | 0, 1, ..., 59 |
646647
+-----------+---------------------------------------+---------------------+
647-
| %-S | Seconds as decimal number | 0, 1, ..., 59 |
648+
| %-S | Seconds as decimal number (**) | 0, 1, ..., 59 |
648649
+-----------+---------------------------------------+---------------------+
649650
| %>H | Total number of hours including days | 0, 1, ..., 100, ... |
651+
| | (***) | |
650652
+-----------+---------------------------------------+---------------------+
651653
| %>M | Total number of minutes including | 0, 1, ..., 100, ... |
652-
| | days and hours | |
654+
| | days and hours (***) | |
653655
+-----------+---------------------------------------+---------------------+
654656
| %>S | Total number of seconds including | 0, 1, ..., 100, ... |
655-
| | days, hours and minutes | |
657+
| | days, hours and minutes (***) | |
656658
+-----------+---------------------------------------+---------------------+
657659
| %f | Microseconds as a decimal number, | 000000, 000001, ... |
658660
| | zero-padded to 6 digits | 999999 |
659661
+-----------+---------------------------------------+---------------------+
660662
663+
- (*): Days are zero-padded to two digits in the C standard. Zero-padding
664+
is not used here, because there is no maximum number of digits
665+
- (**): Support for %-H, %-M, %-S is platform specific in ``strftime``, but
666+
they are always supported in :func:`strftimedelta`.
667+
- (***): %>H, %>M, %>S are extensions to the C standard to support
668+
representations like 3 days as 72 hours, for example.
669+
661670
# TODO: move format code docs to general section at the top
662671
663672
Arguments
@@ -681,7 +690,7 @@ def strftimedelta(td, fmt_str):
681690
# standard implementation for strftime for dates are supported
682691
# >H, >M, >S are total values and not partially consumed by there next
683692
# larger units e.g. for timedelta(days=1.5): d=1, h=12, H=36
684-
values = {'d': int(d), # days; equivalent to c standard
693+
values = {'d': int(d), # days; no zero-padding compared to c std
685694
'>H': int(h_t), # total number of h, m, s;
686695
'>M': int(m_t), # extension to c standard
687696
'>S': int(s_t),
@@ -705,6 +714,8 @@ def strftdnum(td_num, fmt_str):
705714
Return a string representing a matplotlib internal float based timedelta,
706715
controlled by an explicit format string.
707716
717+
# TODO: reference table of format codes
718+
708719
Arguments
709720
---------
710721
td_num : float

0 commit comments

Comments
 (0)
0