MCPcopy
hub / github.com/zvtvz/zvt / to_pd_timestamp

Function to_pd_timestamp

src/zvt/utils/time_utils.py:31–43  ·  view source on GitHub ↗
(the_time, tz=None)

Source from the content-addressed store, hash-verified

29
30# ms(int) or second(float) or str
31def to_pd_timestamp(the_time, tz=None) -> pd.Timestamp | None:
32 if the_time is None:
33 return None
34 # treat int as milliseconds, e.g. return from js
35 if type(the_time) == int:
36 return pd.Timestamp.fromtimestamp(the_time / 1000)
37
38 # treat float as seconds, e.g. return from
39 # timestamp_seconds = time.time()
40 if type(the_time) == float:
41 return pd.Timestamp.fromtimestamp(the_time)
42
43 return pd.Timestamp(the_time, tz=tz)
44
45
46def get_local_timezone():

Callers 15

__init__Method · 0.90
__init__Method · 0.90
generate_domainMethod · 0.90
common_filterFunction · 0.90
is_in_same_intervalFunction · 0.90
next_timestamp_on_levelFunction · 0.90
get_targetsMethod · 0.90
on_trading_closeMethod · 0.90
update_positionMethod · 0.90
__init__Method · 0.90

Calls

no outgoing calls

Tested by 8

test_next_timestampFunction · 0.72
test_get_1min_timestampsFunction · 0.72
test_get_1h_timestampsFunction · 0.72
test_compositeFunction · 0.72
test_composite_allFunction · 0.72
test_000778_spo_detialFunction · 0.72