Skip to content

Commit

Permalink
O3-2476 - isOmrsDateStrict should accept dates with negative timezone…
Browse files Browse the repository at this point in the history
… offsets
  • Loading branch information
mseaton committed Oct 6, 2023
1 parent 0f2bf37 commit 372df7d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/framework/esm-utils/src/omrs-dates.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ describe("Openmrs Dates", () => {
it("checks if a string is openmrs date", () => {
expect(isOmrsDateStrict("2018-03-19T00:00:00.000+0300")).toEqual(true);
expect(isOmrsDateStrict(" 2018-03-19T00:00:00.000+0300 ")).toEqual(true);
expect(isOmrsDateStrict("2023-10-06T12:56:56.065-0400")).toEqual(true);
// the exclusion test cases are important for strictness
expect(isOmrsDateStrict("2018-03-19 00:00:00.000+0300")).toEqual(false);
expect(isOmrsDateStrict("2018-03-19T00:00:00.000+03:00")).toEqual(false);
Expand Down
2 changes: 1 addition & 1 deletion packages/framework/esm-utils/src/omrs-dates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function isOmrsDateStrict(omrsPayloadString: string): boolean {
}

// checking UTC offset format
if (!(omrsPayloadString[23] === "+" && omrsPayloadString[26] !== ":")) {
if (!(omrsPayloadString[23] === "+" || omrsPayloadString[23] === "-")) {
return false;
}

Expand Down

0 comments on commit 372df7d

Please sign in to comment.