Skip to content

Commit

Permalink
Broader coverage for in/out of timezoneless time
Browse files Browse the repository at this point in the history
  • Loading branch information
ctsims committed Oct 28, 2020
1 parent ab538d8 commit 5abf660
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/javarosa/core/model/data/TimeData.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public UncastData uncast() {

@Override
public TimeData cast(UncastData data) throws IllegalArgumentException {
Date ret = DateUtils.parseTime(data.value);
Date ret = DateUtils.parseTime(data.value, true);
if (ret != null) {
return new TimeData(ret);
}
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/org/javarosa/core/model/utils/DateUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,11 @@ private static boolean parseDateAndStore(String dateStr, DateFields df) {
}

public static Date parseTime(String str) {
if (timezoneOffset() != -1 && !str.contains("+") && !str.contains("-") && !str.contains("Z")) {
return parseTime(str, false);
}

public static Date parseTime(String str, boolean ignoreTimezone) {
if (!ignoreTimezone && (timezoneOffset() != -1 && !str.contains("+") && !str.contains("-") && !str.contains("Z"))) {
str = str + getOffsetInStandardFormat(timezoneOffset());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public Object serializeAnswerData(DateTimeData data) {
* formatting
*/
public Object serializeAnswerData(TimeData data) {
return DateUtils.formatTime((Date)data.getValue(), DateUtils.FORMAT_ISO8601);
return DateUtils.formatTime((Date)data.getValue(), DateUtils.FORMAT_ISO8601_WALL_TIME);
}

/**
Expand Down

0 comments on commit 5abf660

Please sign in to comment.