Format timestamps in chrome://metrics-internals as dates. The "Seed Date" and "Client Fetch Time" fields in the Variations Seed Info section of chrome://metrics-internals are now displayed as ISO 8601 formatted dates rather than raw microsecond timestamps. Bug: 452071822 Change-Id: Ic884a979fcbe00dff294012f7e043df47e64bf6d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7184459 Commit-Queue: Ramon Cano Aparicio <rcanoaparicio@google.com> Reviewed-by: Alexei Svitkine <asvitkine@chromium.org> Cr-Commit-Position: refs/heads/main@{#1549590} NOKEYCHECK=True GitOrigin-RevId: 7a2b26ae41ff337344a600c0d28b6237ebf46116
diff --git a/debug/BUILD.gn b/debug/BUILD.gn index 3ba2af8..922ffda 100644 --- a/debug/BUILD.gn +++ b/debug/BUILD.gn
@@ -53,6 +53,7 @@ deps = [ "//base", + "//base:i18n", "//build:branding_buildflags", "//components/metrics", "//components/metrics_services_manager",
diff --git a/debug/metrics_internals_utils.cc b/debug/metrics_internals_utils.cc index 62fe238..5a76019 100644 --- a/debug/metrics_internals_utils.cc +++ b/debug/metrics_internals_utils.cc
@@ -8,12 +8,14 @@ #include <string_view> #include "base/base64.h" +#include "base/i18n/time_formatting.h" #include "base/strings/string_number_conversions.h" #include "build/branding_buildflags.h" #include "build/build_config.h" #include "components/metrics/metrics_pref_names.h" #include "components/variations/client_filterable_state.h" #include "components/variations/proto/study.pb.h" +#include "components/variations/seed_reader_writer.h" #include "components/variations/service/variations_service.h" namespace metrics { @@ -118,6 +120,13 @@ return val ? "Yes" : "No"; } +// Converts a timestamp in microseconds since the Windows epoch to a date +// string. +std::string FormatDate(int64_t timestamp) { + return base::TimeFormatAsIso8601( + variations::SeedReaderWriter::ProtoTimeToTime(timestamp)); +} + base::Value::Dict CreateKeyValueDict(std::string_view key, std::string_view value) { base::Value::Dict dict; @@ -139,9 +148,14 @@ "Seed Milestone", base::NumberToString(stored_seed_info.milestone()))); list.Append(CreateKeyValueDict( "Seed Date", base::NumberToString(stored_seed_info.seed_date()))); + list.Append(CreateKeyValueDict("Seed Date (Formatted)", + FormatDate(stored_seed_info.seed_date()))); list.Append(CreateKeyValueDict( "Client Fetch Time", base::NumberToString(stored_seed_info.client_fetch_time()))); + list.Append( + CreateKeyValueDict("Client Fetch Time (Formatted)", + FormatDate(stored_seed_info.client_fetch_time()))); list.Append(CreateKeyValueDict("Session Country Code", stored_seed_info.session_country_code())); list.Append(CreateKeyValueDict("Permanent Country Code",