@@ -623,41 +623,50 @@ def strftimedelta(td, fmt_str):
623
623
Return a string representing a timedelta, controlled by an explicit
624
624
format string.
625
625
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) .
629
629
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.
631
632
632
633
+-----------+---------------------------------------+---------------------+
633
- | Directive | Meaning | Example |
634
+ | Code | Meaning | Example |
634
635
+-----------+---------------------------------------+---------------------+
635
- | %d | Days | 0, 1, 2, ... |
636
+ | %d | Days (*) | 0, 1, 2, ... |
636
637
+-----------+---------------------------------------+---------------------+
637
638
| %H | Hours as zero-padded decimal number | 00, 01, ..., 23 |
638
639
+-----------+---------------------------------------+---------------------+
639
640
| %M | Minutes as zero-padded decimal number | 00, 01, ..., 59 |
640
641
+-----------+---------------------------------------+---------------------+
641
642
| %S | Seconds as zero-padded decimal number | 00, 01, ..., 59 |
642
643
+-----------+---------------------------------------+---------------------+
643
- | %-H | Hours as decimal number | 0, 1, ..., 23 |
644
+ | %-H | Hours as decimal number (**) | 0, 1, ..., 23 |
644
645
+-----------+---------------------------------------+---------------------+
645
- | %-M | Minutes as decimal number | 0, 1, ..., 59 |
646
+ | %-M | Minutes as decimal number (**) | 0, 1, ..., 59 |
646
647
+-----------+---------------------------------------+---------------------+
647
- | %-S | Seconds as decimal number | 0, 1, ..., 59 |
648
+ | %-S | Seconds as decimal number (**) | 0, 1, ..., 59 |
648
649
+-----------+---------------------------------------+---------------------+
649
650
| %>H | Total number of hours including days | 0, 1, ..., 100, ... |
651
+ | | (***) | |
650
652
+-----------+---------------------------------------+---------------------+
651
653
| %>M | Total number of minutes including | 0, 1, ..., 100, ... |
652
- | | days and hours | |
654
+ | | days and hours (***) | |
653
655
+-----------+---------------------------------------+---------------------+
654
656
| %>S | Total number of seconds including | 0, 1, ..., 100, ... |
655
- | | days, hours and minutes | |
657
+ | | days, hours and minutes (***) | |
656
658
+-----------+---------------------------------------+---------------------+
657
659
| %f | Microseconds as a decimal number, | 000000, 000001, ... |
658
660
| | zero-padded to 6 digits | 999999 |
659
661
+-----------+---------------------------------------+---------------------+
660
662
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
+
661
670
# TODO: move format code docs to general section at the top
662
671
663
672
Arguments
@@ -681,7 +690,7 @@ def strftimedelta(td, fmt_str):
681
690
# standard implementation for strftime for dates are supported
682
691
# >H, >M, >S are total values and not partially consumed by there next
683
692
# 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
685
694
'>H' : int (h_t ), # total number of h, m, s;
686
695
'>M' : int (m_t ), # extension to c standard
687
696
'>S' : int (s_t ),
@@ -705,6 +714,8 @@ def strftdnum(td_num, fmt_str):
705
714
Return a string representing a matplotlib internal float based timedelta,
706
715
controlled by an explicit format string.
707
716
717
+ # TODO: reference table of format codes
718
+
708
719
Arguments
709
720
---------
710
721
td_num : float
0 commit comments