MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _mktime

Method _mktime

tools/python-3.11.9-amd64/Lib/datetime.py:1866–1898  ·  view source on GitHub ↗

Return integer POSIX timestamp.

(self)

Source from the content-addressed store, hash-verified

1864 dst)
1865
1866 def _mktime(self):
1867 """Return integer POSIX timestamp."""
1868 epoch = datetime(1970, 1, 1)
1869 max_fold_seconds = 24 * 3600
1870 t = (self - epoch) // timedelta(0, 1)
1871 def local(u):
1872 y, m, d, hh, mm, ss = _time.localtime(u)[:6]
1873 return (datetime(y, m, d, hh, mm, ss) - epoch) // timedelta(0, 1)
1874
1875 # Our goal is to solve t = local(u) for u.
1876 a = local(t) - t
1877 u1 = t - a
1878 t1 = local(u1)
1879 if t1 == t:
1880 # We found one solution, but it may not be the one we need.
1881 # Look for an earlier solution (if `fold` is 0), or a
1882 # later one (if `fold` is 1).
1883 u2 = u1 + (-max_fold_seconds, max_fold_seconds)[self.fold]
1884 b = local(u2) - u2
1885 if a == b:
1886 return u1
1887 else:
1888 b = t1 - u1
1889 assert a != b
1890 u2 = t - b
1891 t2 = local(u2)
1892 if t2 == t:
1893 return u2
1894 if t1 == t:
1895 return u1
1896 # We have found both offsets a and b, but neither t - a nor t - b is
1897 # a solution. This means t is in the gap.
1898 return (max, min)[self.fold](u1, u2)
1899
1900
1901 def timestamp(self):

Callers 2

timestampMethod · 0.95
_local_timezoneMethod · 0.95

Calls 3

datetimeClass · 0.85
timedeltaClass · 0.85
localClass · 0.85

Tested by

no test coverage detected