Skip to content

Commit 25a14b4

Browse files
committed
Timestamp, serialization, and deprecated cleanup
1 parent 4ce4d21 commit 25a14b4

File tree

10 files changed

+93
-722
lines changed

10 files changed

+93
-722
lines changed

docs/src/GraphData.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,17 @@ Labels are the principle identifier of a variable or factor.
4444

4545
#### Timestamps
4646

47-
Each variable or factor can have a timestamp associated with it.
47+
Each variable or factor can have a timestamp associated with it representing when the physical event/observation occurred.
48+
49+
**Time Standard**: Timestamps use UTC-based time (Coordinated Universal Time) via the `TimeDateZone` type, not TAI (International Atomic Time). The key difference is that UTC includes leap seconds to keep synchronized with Earth's rotation, while TAI is a continuous monotonic time scale without leap seconds.
50+
51+
**Timezone Support**: While timestamps default to UTC (`tz"UTC"`), `TimeDateZone` supports any timezone (e.g., `tz"America/New_York"`, `tz"Europe/London"`). The timezone offset is preserved when stored and retrieved.
52+
53+
**Event Time vs Database Time**: The timestamp represents the physical event time (when a sensor measurement was taken, when a robot was at a pose, etc.), not when the variable was added to the database. Database metadata timestamps may be tracked separately by specific backend implementations.
54+
55+
**Temporal Uncertainty**: This single timestamp value is metadata and does not represent temporal uncertainty in non-parametric beliefs. For problems where time itself is a state variable requiring inference (e.g., using `SGal3` which includes temporal components), include time as part of your state type rather than relying on this metadata field.
56+
57+
Related functions:
4858

4959
- [`getTimestamp`](@ref)
5060

src/Common.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,13 @@ function calcDeltatime(from::TimeDateZone, to::TimeDateZone)
187187
end
188188
calcDeltatime(from_node, to_node) = calcDeltatime(from_node.timestamp, to_node.timestamp)
189189

190-
function tdz_now(zone = tz"UTC") #TODO or default to slower localzone()?
190+
Timestamp(args...) = TimeDateZone(args...)
191+
Timestamp(epoch::Val{:unix}, t::Nanosecond, zone = tz"UTC") = TimeDateZone(TimeDate(1970) + t, zone)
192+
Timestamp(epoch::Val{:unix}, t::Float64, zone = tz"UTC") = Timestamp(epoch, Nanosecond(t * 10^9), zone)
193+
Timestamp(t::Float64, zone = tz"UTC") = Timestamp(Val(:unix), t, zone)
194+
Timestamp(epoch::Val{:rata}, t::Float64, zone = tz"UTC") = TimeDateZone(convert(DateTime,Millisecond(t*10^3)), zone)
195+
196+
function now_tdz(zone = tz"UTC")
191197
t = time()
192-
return TimeDateZone(TimeDate(1970) + Nanosecond(t * 10^9), zone)
198+
return Timestamp(t, zone)
193199
end

src/DataBlobs/entities/BlobEntry.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ StructUtils.@kwarg struct Blobentry
4444
""" Storage for a couple of bytes directly in the graph. Use with caution and keep it small and simple."""
4545
metadata::JSONText = JSONText("{}")
4646
""" When the Blob itself was first created. Serialized as an ISO 8601 string."""
47-
timestamp::TimeDateZone = tdz_now()
47+
timestamp::TimeDateZone = now_tdz()
4848
""" Type version of this Blobentry."""
4949
version::VersionNumber = DFG.version(Blobentry)
5050
end

0 commit comments

Comments
 (0)