Skip to content

Commit

Permalink
Uses new Wikibase timestamp format with year in 4 digits
Browse files Browse the repository at this point in the history
  • Loading branch information
Tpt committed Mar 11, 2018
1 parent ea940f1 commit 8f0ac67
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 19 deletions.
Expand Up @@ -83,7 +83,7 @@ public class TimeValueImpl extends ValueImpl implements TimeValue {
* @param timezoneOffset
* offset in minutes that should be applied when displaying this
* time
* @return a {@link DatatypeIdValue} corresponding to the input
* @return a {@link TimeValue} corresponding to the input
*/
TimeValueImpl(long year, byte month, byte day, byte hour, byte minute,
byte second, byte precision, int beforeTolerance,
Expand Down
Expand Up @@ -41,24 +41,18 @@
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class JacksonInnerTime {
private String time;
private final String time;
private final int timezone;
private final int before;
private final int after;
private final int precision;
private final String calendarmodel;

@JsonIgnore
private long year;
@JsonIgnore
private byte month;
@JsonIgnore
private byte day;
@JsonIgnore
private byte hour;
@JsonIgnore
private byte minute;
@JsonIgnore
private byte second;

/**
Expand Down Expand Up @@ -86,15 +80,15 @@ public class JacksonInnerTime {
@JsonCreator
public JacksonInnerTime(
@JsonProperty("time") String time,
@JsonProperty("timezone") int timezoneOffset,
@JsonProperty("before") int beforeTolerance,
@JsonProperty("after") int afterTolerance,
@JsonProperty("timezone") int timezone,
@JsonProperty("before") int before,
@JsonProperty("after") int after,
@JsonProperty("precision") int precision,
@JsonProperty("calendarmodel") String calendarModel) {
this.time = time;
this.timezone = timezoneOffset;
this.before = beforeTolerance;
this.after = afterTolerance;
this.timezone = timezone;
this.before = before;
this.after = after;
this.precision = precision;
this.calendarmodel = calendarModel;

Expand Down Expand Up @@ -148,8 +142,7 @@ public JacksonInnerTime(long year, byte month, byte day, byte hour,
this.after = after;
this.precision = precision;
this.calendarmodel = calendarModel;

this.composeTimeString();
this.time = composeTimeString();
}

/**
Expand All @@ -171,8 +164,8 @@ private void decomposeTimeString() {
/**
* Helper method to compose the time string from its components.
*/
private void composeTimeString() {
this.time = String.format("%+012d-%02d-%02dT%02d:%02d:%02dZ",
private String composeTimeString() {
return String.format("%+04d-%02d-%02dT%02d:%02d:%02dZ",
this.year, this.month, this.day, this.hour, this.minute,
this.second);
}
Expand Down
Expand Up @@ -88,7 +88,7 @@ public class JsonTestData {
+ "\",\"numeric-id\":" + TEST_NUMERIC_ID + ",\"id\":\"" + TEST_PROPERTY_ID + "\"}}";
public static final String JSON_TIME_VALUE = "{\"type\":\""
+ ValueImpl.JSON_VALUE_TYPE_TIME
+ "\", \"value\":{\"time\":\"+00000002013-10-28T00:00:00Z\",\"timezone\":0,\"before\":0,\"after\":0,\"precision\":11,\"calendarmodel\":\"http://www.wikidata.org/entity/Q1985727\"}}";
+ "\", \"value\":{\"time\":\"+2013-10-28T00:00:00Z\",\"timezone\":0,\"before\":0,\"after\":0,\"precision\":11,\"calendarmodel\":\"http://www.wikidata.org/entity/Q1985727\"}}";
public static final String JSON_GLOBE_COORDINATES_VALUE = "{\"type\":\""
+ ValueImpl.JSON_VALUE_TYPE_GLOBE_COORDINATES
+ "\", \"value\":{\"latitude\":-90.0,\"longitude\":0.0,\"precision\":10.0,\"globe\":\"http://www.wikidata.org/entity/Q2\"}}";
Expand Down

0 comments on commit 8f0ac67

Please sign in to comment.