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

Function _format_time

tools/python-3.11.9-amd64/Lib/datetime.py:161–180  ·  view source on GitHub ↗
(hh, mm, ss, us, timespec='auto')

Source from the content-addressed store, hash-verified

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

Callers 2

isoformatMethod · 0.85
isoformatMethod · 0.85

Calls 1

formatMethod · 0.45

Tested by

no test coverage detected