Skip to content

Commit 5701271

Browse files
committed
Ruby: serialize timestamps as ISO8601
1 parent d944c2b commit 5701271

File tree

3 files changed

+56
-7
lines changed

3 files changed

+56
-7
lines changed

ruby/Cargo.lock

Lines changed: 53 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ruby/extractor/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ encoding = "0.2"
2222
lazy_static = "1.4.0"
2323
serde = { version = "1.0", features = ["derive"] }
2424
serde_json = "1.0"
25+
chrono = { version = "0.4.19", features = ["serde"] }

ruby/extractor/src/diagnostics.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub struct Location {
5656
#[serde(rename_all = "camelCase")]
5757
pub struct DiagnosticMessage {
5858
/** Unix timestamp */
59-
pub timestamp: u64,
59+
pub timestamp: chrono::DateTime<chrono::Utc>,
6060
pub source: Source,
6161
#[serde(skip_serializing_if = "String::is_empty")]
6262
/** GitHub flavored Markdown formatted message. Should include inline links to any help pages. */
@@ -90,10 +90,7 @@ pub struct LogWriter {
9090
impl LogWriter {
9191
pub fn message(&self, id: &str, name: &str) -> DiagnosticMessage {
9292
DiagnosticMessage {
93-
timestamp: std::time::SystemTime::now()
94-
.duration_since(std::time::UNIX_EPOCH)
95-
.expect("")
96-
.as_millis() as u64,
93+
timestamp: chrono::Utc::now(),
9794
source: Source {
9895
id: format!("{}/{}", self.extractor, id),
9996
name: name.to_owned(),

0 commit comments

Comments
 (0)