Skip to content

Commit

Permalink
Switch HistoryEntry to Instant from OffsetDateTime(at UTC) (OpenRefin…
Browse files Browse the repository at this point in the history
  • Loading branch information
tfmorris authored Nov 26, 2023
1 parent f329963 commit 307d8bf
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions main/src/com/google/refine/history/HistoryEntry.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Copyright 2010, Google Inc.
Copyright 2010, 2023 Google Inc. & OpenRefine contributors
All rights reserved.
Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -35,8 +35,8 @@ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT

import java.io.IOException;
import java.io.Writer;
import java.time.Instant;
import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.util.Properties;

import com.fasterxml.jackson.annotation.JacksonInject;
Expand Down Expand Up @@ -69,7 +69,7 @@ public class HistoryEntry {
@JsonProperty("description")
final public String description;
@JsonProperty("time")
final public OffsetDateTime time;
final public Instant time;

// the manager (deals with IO systems or databases etc.)
@JsonIgnore
Expand Down Expand Up @@ -105,15 +105,23 @@ protected HistoryEntry(
@JacksonInject("projectID") long projectID,
@JsonProperty("description") String description,
@JsonProperty(OPERATION) AbstractOperation operation) {
this(id, projectID, description, operation, OffsetDateTime.now(ZoneId.of("Z")));
this(id, projectID, description, operation, Instant.now());
}

public HistoryEntry(long id, Project project, String description, AbstractOperation operation, Change change) {
this(id, project.id, description, operation, OffsetDateTime.now(ZoneId.of("Z")));
this(id, project.id, description, operation, Instant.now());
setChange(change);
}

@Deprecated(since = "3.8")
protected HistoryEntry(long id, long projectID, String description, AbstractOperation operation, OffsetDateTime time) {
// TODO: I'm not sure attempting to preserve this backward compatibility is worthwhile, since:
// a) this constructor is unused in the core, and
// b) there's a public field which has changed datatype
this(id, projectID, description, operation, time.toInstant());
}

protected HistoryEntry(long id, long projectID, String description, AbstractOperation operation, Instant time) {
this.id = id;
this.projectID = projectID;
this.description = description;
Expand Down

0 comments on commit 307d8bf

Please sign in to comment.