Skip to content

Allow time zone designators in temporal coverage times - #2927

Open
rmz-oz wants to merge 1 commit into
NCEAS:developfrom
rmz-oz:bugfix-2840-temporal-coverage-tzd
Open

rmz-oz wants to merge 1 commit into
NCEAS:developfrom
rmz-oz:bugfix-2840-temporal-coverage-tzd

Conversation

@rmz-oz

@rmz-oz rmz-oz commented Oct 1, 2026

Copy link
Copy Markdown

Fixes #2840

Times with an offset like 11:50:00-09:00 failed with "Time must be formatted as HH:MM:SS", but EML types time as xs:time, which allows Z or +/-hh:mm and fractional seconds. validateTimeFormat now strips those before the HH:MM:SS check, and malformed offsets like -9:00 or -15:00 are still rejected. Tests are in EMLTemporalCoverage.spec.js.

- Accept Z, +hh:mm and -hh:mm offsets and fractional seconds (xs:time)
- Add tests for valid and malformed times

Issue NCEAS#2840

@robyngit robyngit left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @rmz-oz for taking this on and adding tests! This timezone issue has come up a few times recently. Editors will really appreciate the fix!

Just an edge case, but validateTimeFormat() allows 24:00:00.1 (>24 hrs) because the fraction is removed before the hour 24 check. I've added an inline suggestion that demonstrates the issue.

Accepting timezones and fractional seconds also affects the existing range validation. These values now pass the format check, but isGreaterTime() still compares time strings, so it doesn't always order them correctly. For example, with both dates set to 2020-01-01:

  • Begin 11:50:00+02:00, end 11:00:00+01:00: should be valid (09:50 to 10:00 UTC), but fails. Reversing this range incorrectly passes.
  • Begin 11:50:00.1Z, end 11:50:00.12Z: should be valid, but fails.

We should update the range comparison to account for offsets and preserve fractional seconds, and add isValid() tests for these ranges.

Happy to help with the comparison logic or tests if needed. Thanks again for working on this!

expect(m.validateTimeFormat("11:50:00+14:00")).to.equal(true);
expect(m.validateTimeFormat("24:00:00-09:00")).to.equal(true);
});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hour 24 should only allow a zero fraction (along with 0 minutes and 0 seconds). This adds a failing case and checks that a zero fraction is still accepted:

Suggested change
it("should require zero fractional seconds when the hour is 24", function () {
var m = new EMLTemporalCoverage();
expect(m.validateTimeFormat("24:00:00.1")).to.be.a("string");
expect(m.validateTimeFormat("24:00:00.000Z")).to.equal(true);
});

@robyngit robyngit linked an issue Oct 7, 2026 that may be closed by this pull request

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Allow Time Zone Designator (TZD) in temporal coverage in web editor

2 participants