Skip to content

[PER-10481] Add EDTF date parsing service#963

Merged
aasandei-vsp merged 1 commit intomainfrom
PER-10481-edtf-service
Mar 20, 2026
Merged

[PER-10481] Add EDTF date parsing service#963
aasandei-vsp merged 1 commit intomainfrom
PER-10481-edtf-service

Conversation

@aasandei-vsp
Copy link
Copy Markdown
Contributor

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

@aasandei-vsp
Copy link
Copy Markdown
Contributor Author

aasandei-vsp commented Mar 11, 2026

@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
Copy link
Copy Markdown

codecov Bot commented Mar 11, 2026

Codecov Report

❌ Patch coverage is 95.61404% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 49.37%. Comparing base (ae0b245) to head (72d5e65).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...c/app/shared/services/edtf-service/edtf.service.ts 95.61% 2 Missing and 3 partials ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@slifty
Copy link
Copy Markdown
Contributor

slifty commented Mar 11, 2026

@aasandei-vsp I was able to run npm i locally (it did tweak the package-lock format, which I think is a byproduct of the recent lock format thrash in npm).

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.

@slifty
Copy link
Copy Markdown
Contributor

slifty commented Mar 11, 2026

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

@aasandei-vsp aasandei-vsp force-pushed the PER-10481-edtf-service branch 2 times, most recently from 4ee2ce7 to 0e14719 Compare March 12, 2026 12:05
Copy link
Copy Markdown
Member

@cecilia-donnelly cecilia-donnelly left a comment

Choose a reason for hiding this comment

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

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);
});
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.

I don't think we want unknown to be true here - I believe unknown is a fully null date.

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.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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}`;
}
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.

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!

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 EdtfService for converting between EDTF strings and a UI-friendly DateTimeModel, plus unit tests.
  • Adds a local src/types/edtf.d.ts module declaration for edtf.
  • 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.

Comment thread src/app/shared/shared.module.ts Outdated
Comment thread src/app/shared/services/edtf-service/edtf.service.ts Outdated
Comment thread src/app/shared/services/edtf-service/edtf.service.ts Outdated
Comment thread src/app/shared/services/edtf-service/edtf.service.ts
Comment thread src/app/shared/services/edtf-service/edtf.service.ts Outdated
Comment thread package.json Outdated
@aasandei-vsp aasandei-vsp force-pushed the PER-10481-edtf-service branch 2 times, most recently from 22a0104 to 951bdbe Compare March 18, 2026 15:12
@slifty slifty self-requested a review March 18, 2026 18:57
Copy link
Copy Markdown
Contributor

@slifty slifty left a comment

Choose a reason for hiding this comment

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

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.

@aasandei-vsp
Copy link
Copy Markdown
Contributor Author

@omnignorant There no testing involved in this ticket, just to make sure the app still loads, because the service is not used anywhere yet.

@aasandei-vsp aasandei-vsp added the QA This issue is ready for QA / user acceptance testing label Mar 19, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 19, 2026

QA Instructions

QA Testing Instructions

Summary

This PR introduces a new service, EdtfService, which parses and converts date/time strings in the Extended Date-Time Format (EDTF) into structured DateTimeModel objects. It also includes functionality for handling partial dates, unknown fields, date qualifiers, ranges/intervals, and timezones. Currently, this service is not exposed as part of the application but is validated via unit tests. Dependencies such as the edtf npm package have been added to support this functionality.

Testing will primarily involve verifying the robustness of EdtfService by running the provided unit tests and ensuring no regressions in the build process.


Test Environment Setup

  1. Pull this branch and install dependencies:
    git pull origin [branch-name]
    npm install
  2. Verify that the edtf package is installed (look for it in node_modules).

Test Scenarios

  1. Verify Unit Tests for EdtfService

    • Steps:
      1. Navigate to the project root directory.
      2. Run the unit test suite:
        npm run test
      3. Filter the tests for the EdtfService to confirm all relevant tests are executed:
        grep -i "EdtfService" src/app/shared/services/edtf-service/edtf.service.spec.ts
    • Expected Results:
      • All tests in src/app/shared/services/edtf-service/edtf.service.spec.ts pass successfully (including scenarios for partial years, time parsing, timezones, and EDTF qualifiers).
      • Reported code coverage for edtf.service.ts should be 100%.
  2. Verify Build Passes with New Dependency

    • Steps:
      1. Ensure the project builds successfully:
        npm run build
    • Expected Results:
      • Build succeeds without errors (e.g., dependency-related issues).
      • Verify that edtf is excluded from prebundling in angular.json under the serve configuration.
  3. Manual Validation of Edge Test Cases with EdtfService
    (Optional if further testing is necessary after unit tests)

    • Steps:
      1. Manually create a test harness or mock usage of EdtfService in a sandbox application component (not included in the PR).
      2. Provide input strings such as:
        • Complete date and time: 1985-05-20T14:30:00Z
        • Partial year: 19XX or 1XXX
        • Unknown field: 1985-XX
      3. Capture the returned DateTimeModel and verify data consistency.
    • Expected Results:
      • Outputs correctly match the expected DateTimeModel structure for each scenario. Look for both correct parsing and handling of error cases (e.g., invalid formats).

Regression Risks

  • Build Process:
    Adding a new dependency (edtf) and modifying angular.json to exclude edtf from prebundling might introduce risks for build environments.
  • Shared Component/Service Dependencies:
    While the service is not yet exposed to the UI, potential conflicts with other date/time-related services or libraries (e.g., date-fns, moment) could arise in the future.

Things to Watch For

  1. Ensure strict alignment with the EDTF specification for parsing ranges, qualifiers, and unknown fields.
  2. Confirm no unintended side effects occur when introducing edtf to dependency resolution and bundling processes.

Additional Notes

No 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
@aasandei-vsp aasandei-vsp force-pushed the PER-10481-edtf-service branch from 951bdbe to 72d5e65 Compare March 20, 2026 08:56
@aasandei-vsp aasandei-vsp merged commit fca0d4b into main Mar 20, 2026
16 checks passed
@aasandei-vsp aasandei-vsp deleted the PER-10481-edtf-service branch March 20, 2026 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

QA This issue is ready for QA / user acceptance testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants