Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to display timestamps in the local system timezone #3530

Merged
merged 13 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions crates/re_arrow_store/examples/range_components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fn main() {
"Found data at time {} from {}'s PoV (outer-joining):\n{}",
time.map_or_else(
|| "<timeless>".into(),
|time| TimeType::Sequence.format(time)
|time| TimeType::Sequence.format_utc(time)
),
LargeStruct::name(),
df,
Expand All @@ -87,7 +87,7 @@ fn main() {
"Found data at time {} from {}'s PoV (outer-joining):\n{}",
time.map_or_else(
|| "<timeless>".into(),
|time| TimeType::Sequence.format(time)
|time| TimeType::Sequence.format_utc(time)
),
Position2D::name(),
df,
Expand Down
8 changes: 6 additions & 2 deletions crates/re_arrow_store/src/store_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use re_format::{format_bytes, format_number};
use re_log_types::SizeBytes as _;

use crate::{DataStore, IndexedBucket, IndexedTable, PersistentIndexedTable};
use re_log_types::TimeZone;

// --- Data store ---

Expand Down Expand Up @@ -102,7 +103,10 @@ impl std::fmt::Display for IndexedTable {
f.write_str(&indent::indent_all_by(4, "IndexedBucket {\n"))?;
f.write_str(&indent::indent_all_by(
8,
format!("index time bound: >= {}\n", timeline.typ().format(*time),),
format!(
"index time bound: >= {}\n",
timeline.typ().format_utc(*time)
),
))?;
f.write_str(&indent::indent_all_by(8, bucket.to_string()))?;
f.write_str(&indent::indent_all_by(4, "}\n"))?;
Expand All @@ -124,7 +128,7 @@ impl std::fmt::Display for IndexedBucket {
let time_range = {
let time_range = &self.inner.read().time_range;
if time_range.min.as_i64() != i64::MAX && time_range.max.as_i64() != i64::MIN {
self.timeline.format_time_range(time_range)
self.timeline.format_time_range(time_range, TimeZone::Utc)
Wumpf marked this conversation as resolved.
Show resolved Hide resolved
} else {
"time range: N/A\n".to_owned()
}
Expand Down
34 changes: 17 additions & 17 deletions crates/re_arrow_store/src/store_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl std::fmt::Debug for LatestAtQuery {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_fmt(format_args!(
"<latest at {} on {:?} (including timeless)>",
self.timeline.typ().format(self.at),
self.timeline.typ().format_utc(self.at),
self.timeline.name(),
))
}
Expand Down Expand Up @@ -58,8 +58,8 @@ impl std::fmt::Debug for RangeQuery {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_fmt(format_args!(
"<ranging from {} to {} (all inclusive) on {:?} ({} timeless)>",
self.timeline.typ().format(self.range.min),
self.timeline.typ().format(self.range.max),
self.timeline.typ().format_utc(self.range.min),
self.timeline.typ().format_utc(self.range.max),
self.timeline.name(),
if self.range.min == TimeInt::MIN {
"including"
Expand Down Expand Up @@ -513,11 +513,11 @@ impl IndexedTable {
trace!(
kind = "latest_at",
timeline = %timeline.name(),
time = timeline.typ().format(time),
time = timeline.typ().format_utc(time),
%primary,
?components,
attempt,
bucket_time_range = timeline.typ().format_range(bucket.inner.read().time_range),
bucket_time_range = timeline.typ().format_range_utc(bucket.inner.read().time_range),
"found candidate bucket"
);
if let cells @ Some(_) = bucket.latest_at(time, primary, components) {
Expand Down Expand Up @@ -560,7 +560,7 @@ impl IndexedTable {
kind = "range",
bucket_nr,
bucket_time_range =
timeline.typ().format_range(bucket.inner.read().time_range),
timeline.typ().format_range_utc(bucket.inner.read().time_range),
timeline = %timeline.name(),
?time_range,
?components,
Expand Down Expand Up @@ -715,7 +715,7 @@ impl IndexedBucket {
%primary,
?components,
timeline = %self.timeline.name(),
time = self.timeline.typ().format(time),
time = self.timeline.typ().format_utc(time),
"searching for primary & secondary cells…"
);

Expand All @@ -736,7 +736,7 @@ impl IndexedBucket {
%primary,
?components,
timeline = %self.timeline.name(),
time = self.timeline.typ().format(time),
time = self.timeline.typ().format_utc(time),
%primary_row_nr,
"found primary row number",
);
Expand All @@ -750,7 +750,7 @@ impl IndexedBucket {
%primary,
?components,
timeline = %self.timeline.name(),
time = self.timeline.typ().format(time),
time = self.timeline.typ().format_utc(time),
%primary_row_nr,
"no secondary row number found",
);
Expand All @@ -764,7 +764,7 @@ impl IndexedBucket {
%primary,
?components,
timeline = %self.timeline.name(),
time = self.timeline.typ().format(time),
time = self.timeline.typ().format_utc(time),
%primary_row_nr, %secondary_row_nr,
"found secondary row number",
);
Expand All @@ -779,7 +779,7 @@ impl IndexedBucket {
%primary,
%component,
timeline = %self.timeline.name(),
time = self.timeline.typ().format(time),
time = self.timeline.typ().format_utc(time),
%primary_row_nr, %secondary_row_nr,
"found cell",
);
Expand Down Expand Up @@ -836,21 +836,21 @@ impl IndexedBucket {

trace!(
kind = "range",
bucket_time_range = self.timeline.typ().format_range(bucket_time_range),
bucket_time_range = self.timeline.typ().format_range_utc(bucket_time_range),
?components,
timeline = %self.timeline.name(),
time_range = self.timeline.typ().format_range(time_range),
time_range = self.timeline.typ().format_range_utc(time_range),
"searching for time & component cell numbers…"
);

let time_row_nr = col_time.partition_point(|t| *t < time_range.min.as_i64()) as u64;

trace!(
kind = "range",
bucket_time_range = self.timeline.typ().format_range(bucket_time_range),
bucket_time_range = self.timeline.typ().format_range_utc(bucket_time_range),
?components,
timeline = %self.timeline.name(),
time_range = self.timeline.typ().format_range(time_range),
time_range = self.timeline.typ().format_range_utc(time_range),
%time_row_nr,
"found time row number",
);
Expand Down Expand Up @@ -896,10 +896,10 @@ impl IndexedBucket {
trace!(
kind = "range",
bucket_time_range =
self.timeline.typ().format_range(bucket_time_range),
self.timeline.typ().format_range_utc(bucket_time_range),
?components,
timeline = %self.timeline.name(),
time_range = self.timeline.typ().format_range(time_range),
time_range = self.timeline.typ().format_range_utc(time_range),
%row_nr,
%row_id,
?cells,
Expand Down
4 changes: 2 additions & 2 deletions crates/re_arrow_store/src/store_sanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ impl IndexedTable {
if t1.max.as_i64() >= t2.min.as_i64() {
return Err(SanityError::OverlappingBuckets {
t1_max: t1.max.as_i64(),
t1_max_formatted: self.timeline.typ().format(t1.max),
t1_max_formatted: self.timeline.typ().format_utc(t1.max),
t2_max: t2.max.as_i64(),
t2_max_formatted: self.timeline.typ().format(t2.max),
t2_max_formatted: self.timeline.typ().format_utc(t2.max),
});
}
}
Expand Down
20 changes: 11 additions & 9 deletions crates/re_arrow_store/src/store_write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use smallvec::SmallVec;
use re_log::{debug, trace};
use re_log_types::{
DataCell, DataCellColumn, DataCellError, DataRow, DataTable, RowId, SizeBytes as _, TimeInt,
TimePoint, TimeRange,
TimePoint, TimeRange, TimeZone,
};
use re_types::{components::InstanceKey, ComponentName, ComponentNameSet, Loggable};

Expand Down Expand Up @@ -128,7 +128,7 @@ impl DataStore {
id = self.insert_id,
cluster_key = %self.cluster_key,
timelines = ?timepoint.iter()
.map(|(timeline, time)| (timeline.name(), timeline.typ().format(*time)))
.map(|(timeline, time)| (timeline.name(), timeline.typ().format_utc(*time)))
.collect::<Vec<_>>(),
entity = %ent_path,
components = ?cells.iter().map(|cell| cell.component_name()).collect_vec(),
Expand Down Expand Up @@ -303,11 +303,11 @@ impl IndexedTable {
trace!(
kind = "insert",
timeline = %timeline.name(),
time = timeline.typ().format(time),
time = timeline.typ().format_utc(time),
entity = %ent_path,
len_limit = config.indexed_bucket_num_rows,
len, len_overflow,
new_time_bound = timeline.typ().format(min),
new_time_bound = timeline.typ().format_utc(min),
"splitting off indexed bucket following overflow"
);

Expand Down Expand Up @@ -353,11 +353,11 @@ impl IndexedTable {
debug!(
kind = "insert",
timeline = %timeline.name(),
time = timeline.typ().format(time),
time = timeline.typ().format_utc(time),
entity = %ent_path,
len_limit = config.indexed_bucket_num_rows,
len, len_overflow,
new_time_bound = timeline.typ().format(new_time_bound.into()),
new_time_bound = timeline.typ().format_utc(new_time_bound.into()),
"creating brand new indexed bucket following overflow"
);

Expand Down Expand Up @@ -388,7 +388,9 @@ impl IndexedTable {

re_log::debug_once!(
"Failed to split bucket on timeline {}",
bucket.timeline.format_time_range(&bucket_time_range)
bucket
.timeline
.format_time_range(&bucket_time_range, TimeZone::Utc)
);

if 1 < config.indexed_bucket_num_rows
Expand All @@ -398,7 +400,7 @@ impl IndexedTable {
"Found over {} rows with the same timepoint {:?}={} - perhaps you forgot to update or remove the timeline?",
config.indexed_bucket_num_rows,
bucket.timeline.name(),
bucket.timeline.typ().format(bucket_time_range.min)
bucket.timeline.typ().format_utc(bucket_time_range.min)
);
}
}
Expand All @@ -407,7 +409,7 @@ impl IndexedTable {
trace!(
kind = "insert",
timeline = %timeline.name(),
time = timeline.typ().format(time),
time = timeline.typ().format_utc(time),
entity = %ent_path,
?components,
"inserted into indexed tables"
Expand Down
7 changes: 6 additions & 1 deletion crates/re_data_ui/src/item_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,12 @@ pub fn time_button(
) -> egui::Response {
let is_selected = ctx.rec_cfg.time_ctrl.is_time_selected(timeline, value);

let response = ui.selectable_label(is_selected, timeline.typ().format(value));
let response = ui.selectable_label(
is_selected,
timeline
.typ()
.format(value, ctx.app_options.time_zone_for_timestamps),
);
if response.clicked() {
ctx.rec_cfg
.time_ctrl
Expand Down
2 changes: 1 addition & 1 deletion crates/re_data_ui/src/log_msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl DataUi for SetStoreInfo {
ui.end_row();

ui.monospace("started:");
ui.label(started.format());
ui.label(started.format(_ctx.app_options.time_zone_for_timestamps));
ui.end_row();

ui.monospace("store_source:");
Expand Down
2 changes: 1 addition & 1 deletion crates/re_log_types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ num-traits.workspace = true
similar-asserts.workspace = true
smallvec.workspace = true
thiserror.workspace = true
time = { workspace = true, features = ["formatting", "macros"] }
time = { workspace = true, features = ["formatting", "macros", "local-offset"] }
typenum.workspace = true
uuid = { workspace = true, features = ["serde", "v4", "js"] }
web-time.workspace = true
Expand Down
7 changes: 6 additions & 1 deletion crates/re_log_types/src/data_row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,12 @@ impl std::fmt::Display for DataRow {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
writeln!(f, "Row #{} @ '{}'", self.row_id, self.entity_path)?;
for (timeline, time) in &self.timepoint {
writeln!(f, "- {}: {}", timeline.name(), timeline.typ().format(*time))?;
writeln!(
f,
"- {}: {}",
timeline.name(),
timeline.typ().format_utc(*time)
)?;
}

re_format::arrow::format_table(
Expand Down
2 changes: 1 addition & 1 deletion crates/re_log_types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub use self::data_table::{
};
pub use self::index::*;
pub use self::path::*;
pub use self::time::{Duration, Time};
pub use self::time::{Duration, Time, TimeZone};
pub use self::time_point::{TimeInt, TimePoint, TimeType, Timeline, TimelineName};
pub use self::time_range::{TimeRange, TimeRangeF};
pub use self::time_real::TimeReal;
Expand Down
Loading
Loading