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

Function _format_time

Lib/_pydatetime.py:166–185  ·  view source on GitHub ↗
(hh, mm, ss, us, timespec='auto')

Source from the content-addressed store, hash-verified

164 return _time.struct_time((y, m, d, hh, mm, ss, wday, dnum, dstflag))
165
166def _format_time(hh, mm, ss, us, timespec='auto'):
167 specs = {
168 'hours': '{:02d}',
169 'minutes': '{:02d}:{:02d}',
170 'seconds': '{:02d}:{:02d}:{:02d}',
171 'milliseconds': '{:02d}:{:02d}:{:02d}.{:03d}',
172 'microseconds': '{:02d}:{:02d}:{:02d}.{:06d}'
173 }
174
175 if timespec == 'auto':
176 # Skip trailing microseconds when us==0.
177 timespec = 'microseconds' if us else 'seconds'
178 elif timespec == 'milliseconds':
179 us //= 1000
180 try:
181 fmt = specs[timespec]
182 except KeyError:
183 raise ValueError('Unknown timespec value')
184 else:
185 return fmt.format(hh, mm, ss, us)
186
187def _format_offset(off, sep=':'):
188 s = ''

Callers 2

isoformatMethod · 0.85
isoformatMethod · 0.85

Calls 1

formatMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…