MCPcopy Create free account
hub / github.com/apache/arrow / format_timestamp

Function format_timestamp

cpp/gdb_arrow.py:296–314  ·  view source on GitHub ↗

Format a timestamp value.

(val, unit)

Source from the content-addressed store, hash-verified

294
295
296def format_timestamp(val, unit):
297 """
298 Format a timestamp value.
299 """
300 val = int(val)
301 unit = int(unit)
302 short_unit = short_time_unit(unit)
303 traits = time_unit_traits[unit]
304 seconds, subseconds = divmod(val, traits.multiplier)
305 try:
306 dt = datetime.datetime.utcfromtimestamp(seconds)
307 except (ValueError, OSError, OverflowError):
308 # value out of range for datetime.datetime
309 pretty = "too large to represent"
310 else:
311 pretty = dt.isoformat().replace('T', ' ')
312 if traits.fractional_digits > 0:
313 pretty += f".{subseconds:0{traits.fractional_digits}d}"
314 return f"{val}{short_unit} [{pretty}]"
315
316
317def cast_to_concrete(val, ty):

Callers 1

_format_valueMethod · 0.85

Calls 1

short_time_unitFunction · 0.85

Tested by

no test coverage detected