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

Function format_timestamp

cpp/gdb_arrow.py:298–316  ·  view source on GitHub ↗

Format a timestamp value.

(val, unit)

Source from the content-addressed store, hash-verified

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

Callers 1

_format_valueMethod · 0.85

Calls 1

short_time_unitFunction · 0.85

Tested by

no test coverage detected