MCPcopy Index your code
hub / github.com/python/cpython / stats

Method stats

Lib/test/datetimetester.py:6745–6790  ·  view source on GitHub ↗
(cls, start_year=1)

Source from the content-addressed store, hash-verified

6743
6744 @classmethod
6745 def stats(cls, start_year=1):
6746 count = gap_count = fold_count = zeros_count = 0
6747 min_gap = min_fold = timedelta.max
6748 max_gap = max_fold = ZERO
6749 min_gap_datetime = max_gap_datetime = datetime.min
6750 min_gap_zone = max_gap_zone = None
6751 min_fold_datetime = max_fold_datetime = datetime.min
6752 min_fold_zone = max_fold_zone = None
6753 stats_since = datetime(start_year, 1, 1) # Starting from 1970 eliminates a lot of noise
6754 for zonename in cls.zonenames():
6755 count += 1
6756 tz = cls.fromname(zonename)
6757 for dt, shift in tz.transitions():
6758 if dt < stats_since:
6759 continue
6760 if shift > ZERO:
6761 gap_count += 1
6762 if (shift, dt) > (max_gap, max_gap_datetime):
6763 max_gap = shift
6764 max_gap_zone = zonename
6765 max_gap_datetime = dt
6766 if (shift, datetime.max - dt) < (min_gap, datetime.max - min_gap_datetime):
6767 min_gap = shift
6768 min_gap_zone = zonename
6769 min_gap_datetime = dt
6770 elif shift < ZERO:
6771 fold_count += 1
6772 shift = -shift
6773 if (shift, dt) > (max_fold, max_fold_datetime):
6774 max_fold = shift
6775 max_fold_zone = zonename
6776 max_fold_datetime = dt
6777 if (shift, datetime.max - dt) < (min_fold, datetime.max - min_fold_datetime):
6778 min_fold = shift
6779 min_fold_zone = zonename
6780 min_fold_datetime = dt
6781 else:
6782 zeros_count += 1
6783 trans_counts = (gap_count, fold_count, zeros_count)
6784 print("Number of zones: %5d" % count)
6785 print("Number of transitions: %5d = %d (gaps) + %d (folds) + %d (zeros)" %
6786 ((sum(trans_counts),) + trans_counts))
6787 print("Min gap: %16s at %s in %s" % (min_gap, min_gap_datetime, min_gap_zone))
6788 print("Max gap: %16s at %s in %s" % (max_gap, max_gap_datetime, max_gap_zone))
6789 print("Min fold: %16s at %s in %s" % (min_fold, min_fold_datetime, min_fold_zone))
6790 print("Max fold: %16s at %s in %s" % (max_fold, max_fold_datetime, max_fold_zone))
6791
6792
6793 def transitions(self):

Callers

nothing calls this directly

Calls 4

datetimeClass · 0.90
zonenamesMethod · 0.80
fromnameMethod · 0.45
transitionsMethod · 0.45

Tested by

no test coverage detected