Skip to content

Commit

Permalink
Bug half time zone (#1313)
Browse files Browse the repository at this point in the history
* Fix fractional timezone offsets

* Enable relevant FHIRPath tests
  • Loading branch information
JPercival authored Jan 8, 2024
1 parent 2836402 commit a293213
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ private Expression parseDateTimeLiteral(String input) {
}

result.setTimezoneOffset(libraryBuilder.createLiteral(
(double) (hourOffset + (minuteOffset / 60)) * offsetPolarity));
(double) (hourOffset + ((double) minuteOffset / 60)) * offsetPolarity));
} else {
if (matcher.group(26) != null) {
int hourOffset = Integer.parseInt(matcher.group(26));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ public void dateTimeLiteralTests() throws IOException {

def = defs.get("UTCDateLiteral");
assertThat(def, hasTypeAndResult(DateTime.class, "System.DateTime"));

def = defs.get("TimeZoneHalfHourLiteral");
assertThat(def, hasTypeAndResult(DateTime.class, "System.DateTime"));
dateTime = (DateTime) def.getExpression();
assertThat(dateTime.getTimezoneOffset(), literalFor(1.5));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ define UTCDateTimeLiteral: @2014-02-12T10:30:15.0000Z
define TimeZoneDateTimeLiteral: @2014-02-12T10:30:15.0000-07:00
define TimeZonePositiveDateTimeLiteral: @2014-02-12T10:30:15.0000+07:00

// Test for https://github.com/cqframework/clinical_quality_language/issues/1298
define TimeZoneHalfHourLiteral: @2014-01-01T12:05:05.955+01:30

define YearExpression: 1 year
define YearsExpression: 10 years
define MonthExpression: 1 month
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@ public static Object[][] dataMethod() {
"cql/CqlTypeOperatorsTest/As/CastAsQuantity",
"cql/CqlTypeOperatorsTest/Convert/StringToDateTimeMalformed",
"cql/CqlTypeOperatorsTest/Convert/StringToIntegerError",
"cql/CqlTypeOperatorsTest/ToDateTime/ToDateTime4",
"cql/CqlTypeOperatorsTest/ToDateTime/ToDateTime5",
"cql/CqlTypeOperatorsTest/ToDateTime/ToDateTimeMalformed",
"cql/CqlTypeOperatorsTest/ToTime/ToTime2",
"cql/CqlTypeOperatorsTest/ToTime/ToTime3",
Expand Down

0 comments on commit a293213

Please sign in to comment.