Changing Reference Frames
Moving to an Absolute Time
t0 = Time('2020-03-05 21:00 +0800')
my_db_state_ref | time_travel[t0] # returns a db_state_ref
my_eternal_ref | time_travel[t0] # returns a db_state_ref
my_db_state | time_travel[t0] # returns a db_state
db | time_travel[t0] # returns a db_state
Moving to the Latest State
Using now
is an impure operation: it may return different results during different executions. It also couples logical time (data) with real time (when does it run).
my_db_state_ref | now # returns a db_state_ref
my_eternal_ref | now # returns a db_state_ref
my_db_state | now # returns a db_state
db | now # returns a db_state
Moving Relatively by Fixed Durations
t0 = Time('2020-03-05 21:00 +0800')
my_db_state_ref | time_travel[-4*units.hour]
my_db_state | time_travel[-4*units.hour]
Note that this does not work on DBs and eternal refs: these data structures have no inherent concept of time relative to which one can move
Moving a Fixed Number of Steps in Logical Time
t0 = Time('2020-03-05 21:00 +0800')
my_db_state_ref | time_travel[-2]
my_db_state | time_travel[2]
Passing an integer to the time travel operator means: move this fixed number of steps in logical states.
Successive states are numbered consecutively in each DB: the transitions to a new state are generated by a transaction.
Moving to a Fixed Reference Frame
A DBState (the "time slice of a ZefDB at a given time") is a concrete instances of reference frame.
To move an atom to a specific frame, you can use
my_eternal_ref | to_frame[my_db_state]
my_state_ref | to_frame[my_db_state]
my_platonic_ref | to_frame[my_db_state]
All of these presuppose that the atom exists in the specified frame, otherwise an Error is returned.
Error Cases
For all of the above cases, if the implied time lies outside of the bounds of the graph (prior to the first GraphSlice or later than the last GraphSlice present), an Error is returned.