Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/elm/datetime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
});
}
}
Expand Down
26 changes: 26 additions & 0 deletions test/elm/datetime/datetime-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Loading