[PER-10481] Add EDTF date parsing service#963
Conversation
|
@slifty Do you think you could try and run this locally? I had some issues with installing the package locally as well and it seems the build fails on the PR too. Do you think you could have a look? |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #963 +/- ##
==========================================
+ Coverage 48.97% 49.37% +0.40%
==========================================
Files 351 352 +1
Lines 11359 11473 +114
Branches 1901 1946 +45
==========================================
+ Hits 5563 5665 +102
- Misses 5603 5615 +12
Partials 193 193 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@aasandei-vsp I was able to run I'm on node 24.13.0 and npm 11.11.0 I haven't yet rebuilt docker, but wanted to give context to the "fix package lock" commit above which appears to at least fix CI. |
|
Looks like the local issue was related to esm / cjs -- apparently the solution is to instruct vite to ignore it during the prebundle step (I admit that even still I'm not fully adept at the nuances of esm) I put these as commits so you see 'em but really they should just be fixup'd into your original introduction of the lib |
4ee2ce7 to
0e14719
Compare
cecilia-donnelly
left a comment
There was a problem hiding this comment.
This is so fancy, @aasandei-vsp ! I love it. Other than the unknown bit I flagged this looks correct. I can imagine finding other edge cases as we test, but you've organized this really clearly. Thank you!
| const result = service.toDateTimeModel('1985-XX'); | ||
|
|
||
| expect(result.qualifiers.unknown).toBe(true); | ||
| }); |
There was a problem hiding this comment.
I don't think we want unknown to be true here - I believe unknown is a fully null date.
There was a problem hiding this comment.
Getting this from "the extended interval syntax keywords 'unknown' and 'open' have been replaced with null and the double-dot notation ['..'] respectively; " on the spec.
There was a problem hiding this comment.
I've added this in the parsing of the date object. It should return the correct format for the interval.
| } | ||
|
|
||
| return `${year}-${date.month}-${date.day}`; | ||
| } |
There was a problem hiding this comment.
I would expect this to return '2026-XX-XX' for something that happened in this year, not just '2026' -- am I misunderstanding? It looks like either is valid, though! "The character 'X' may be used in place of one or more rightmost digits to indicate that the value of that digit is unspecified" -- may so either works. Okay, no action needed!
0e14719 to
6fc163c
Compare
There was a problem hiding this comment.
Pull request overview
Adds an internal Angular service for parsing/building EDTF date strings, along with local TypeScript typings and dependency/config updates to support the edtf npm package.
Changes:
- Introduces
EdtfServicefor converting between EDTF strings and a UI-friendlyDateTimeModel, plus unit tests. - Adds a local
src/types/edtf.d.tsmodule declaration foredtf. - Adds
edtf(and related config/deps) to the project and excludes it from Angular dev-server prebundling.
Reviewed changes
Copilot reviewed 5 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/types/edtf.d.ts | Adds local TS typings for the edtf package. |
| src/app/shared/shared.module.ts | Registers EdtfService in SharedModule (in addition to providedIn: 'root'). |
| src/app/shared/services/edtf-service/edtf.service.ts | Implements EDTF parsing/formatting + validation helpers. |
| src/app/shared/services/edtf-service/edtf.service.spec.ts | Adds unit tests covering parsing, formatting, validation, and roundtrips. |
| package.json | Adds edtf (and encoding) dependencies. |
| package-lock.json | Locks new dependencies pulled in by the additions. |
| angular.json | Excludes edtf from dev-server prebundling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
22a0104 to
951bdbe
Compare
There was a problem hiding this comment.
I think this is looking good / all the raised issues on my end have been resolved (and it's now smooshed into one commit hooray!)
I defer to you on whether @cecilia-donnelly's questions are covered.
|
@omnignorant There no testing involved in this ticket, just to make sure the app still loads, because the service is not used anywhere yet. |
QA InstructionsQA Testing InstructionsSummaryThis PR introduces a new service, Testing will primarily involve verifying the robustness of Test Environment Setup
Test Scenarios
Regression Risks
Things to Watch For
Additional NotesNo UI integrations are introduced in this PR, so this service cannot yet be manually tested within the application. Validation heavily relies on the provided unit tests. Generated by QA Instructions Action |
… structured date/time models Introduces EdtfService that handles parsing EDTF (Extended Date Time Format) strings into structured DateTimeModel objects and converting them back. Supports partial years, unspecified fields (XX), date qualifiers (approximate, uncertain), date ranges/intervals, 12-hour AM/PM time conversion, and timezone extraction. Includes validation methods for dates and times, along with comprehensive unit tests and type declarations for the edtf npm package. Issue: PER-10481
951bdbe to
72d5e65
Compare
This service is not exposed in any way yet, so it can't be tested. It is only validated atm by unit tests.
The only thing that might cause problems at build time would be the edtf package.
Issue: PER-10481