From acf0378e925f1ffd4a3e39bbc393060635e34984 Mon Sep 17 00:00:00 2001 From: Bryant Austin Date: Mon, 26 Oct 2026 14:19:57 -0600 Subject: [PATCH] Keep the fractional execution timezone offset when defaulting a DateTime's offset DateTime.exec filled in a missing timezoneOffset with an Integer literal, and IntegerLiteral's parseInt dropped the fraction: a +05:30 execution offset became +05:00. Use a Decimal literal so offset-less DateTime literals and selectors get the same offset as Now() and ToDateTime(String). Co-Authored-By: Claude Opus 5.5 --- src/elm/datetime.ts | 4 ++-- test/elm/datetime/datetime-test.ts | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/elm/datetime.ts b/src/elm/datetime.ts index c52cf290f..f60468638 100644 --- a/src/elm/datetime.ts +++ b/src/elm/datetime.ts @@ -3,7 +3,7 @@ import { build } from './builder'; import { Literal } from './literal'; import * as DT from '../datatypes/datatypes'; import { Context } from '../runtime/context'; -import { ELM_INTEGER_TYPE } from '../util/elmTypes'; +import { ELM_DECIMAL_TYPE } from '../util/elmTypes'; export class DateTime extends Expression { json: any; @@ -35,7 +35,7 @@ export class DateTime extends Expression { this[property] = Literal.from({ type: 'Literal', value: ctx.getTimezoneOffset(), - valueType: ELM_INTEGER_TYPE + valueType: ELM_DECIMAL_TYPE }); } } diff --git a/test/elm/datetime/datetime-test.ts b/test/elm/datetime/datetime-test.ts index bc35d166e..baa848d30 100644 --- a/test/elm/datetime/datetime-test.ts +++ b/test/elm/datetime/datetime-test.ts @@ -102,6 +102,32 @@ describe('DateTime', () => { d.millisecond.should.equal(456); d.timezoneOffset.should.equalDecimal(-8); }); + + it('should default to a fractional execution timezone offset', async function () { + this.ctx = new PatientContext( + this.ctx.library, + this.ctx.patient, + this.ctx.codeService, + this.ctx.parameters, + DT.DateTime.fromJSDate(new Date(), 5.5) + ); + const d = await this.minute.exec(this.ctx); + d.minute.should.equal(10); + d.timezoneOffset.should.equalDecimal(5.5); + }); + + it('should default to a negative fractional execution timezone offset', async function () { + this.ctx = new PatientContext( + this.ctx.library, + this.ctx.patient, + this.ctx.codeService, + this.ctx.parameters, + DT.DateTime.fromJSDate(new Date(), -9.5) + ); + const d = await this.minute.exec(this.ctx); + d.minute.should.equal(10); + d.timezoneOffset.should.equalDecimal(-9.5); + }); }); describe('Time', () => {