Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to date and time utils from frontend-shared #6587

Merged
merged 2 commits into from
Oct 4, 2024

Conversation

acelaya
Copy link
Contributor

@acelaya acelaya commented Oct 1, 2024

Depends on hypothesis/frontend-shared#1726

Use date utils from frontend-shared instead of local implementations.

Additionally, a remaining standalone function called formatDateTime has been renamed to formatSortableDateTime, to differentiate from the formatDateTime now provided by frontend-shared.

The reason to choose this name is that the format returned by this function is YYYY-MM-DD hh:mm, which produces values that are sorted chronologically when sorted alphabetically.

TODO

  • Find a better name for the local formatDateTime function, to avoid confusions with frontend-shared one, which returns a different format.

@acelaya acelaya marked this pull request as ready for review October 2, 2024 10:36
@acelaya acelaya marked this pull request as draft October 2, 2024 10:36
Copy link

codecov bot commented Oct 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.42%. Comparing base (a6bc6a9) to head (3f3c9cd).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6587      +/-   ##
==========================================
- Coverage   99.43%   99.42%   -0.01%     
==========================================
  Files         270      270              
  Lines       10240    10169      -71     
  Branches     2425     2417       -8     
==========================================
- Hits        10182    10111      -71     
  Misses         58       58              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@acelaya acelaya marked this pull request as ready for review October 2, 2024 11:56
Copy link
Member

@robertknight robertknight left a comment

Choose a reason for hiding this comment

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

In reviewing this I realized that we've lost the context around why we use this particular date time format for text exports. I think the rationale was to have a human friendly version of the ISO date time format. Can you remember any other reasons? Lexicographic sortability isn't an obviously critical thing in this context.

@@ -91,7 +91,7 @@ export class AnnotationsExporter {
const page = pageLabel(annotation);
const annotationQuote = quote(annotation);
const lines = [
`Created at: ${formatDateTime(new Date(annotation.created))}`,
`Created at: ${formatSortableDateTime(new Date(annotation.created))}`,
Copy link
Member

Choose a reason for hiding this comment

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

Can you remind me why we needed to use a date/time format that has this lexicograph / chronological sorting equivalence?

#6079 was the PR that introduced the change, but the only rationale in that PR was to have a more human-friendly form of the ISO date.

@acelaya
Copy link
Contributor Author

acelaya commented Oct 2, 2024

In reviewing this I realized that we've lost the context around why we use this particular date time format for text exports. I think the rationale was to have a human friendly version of the ISO date time format. Can you remember any other reasons? Lexicographic sortability isn't an obviously critical thing in this context.

Yeah... This is unfortunate, but I also don't fully remember why we choose this particular format.

I can only guess it was so that in the case of, for example, CSV, resulting datasets could be sorted by that column, but I'm only speculating here.

I'll try to dig a bit further into old discussions and PRs.

@acelaya
Copy link
Contributor Author

acelaya commented Oct 3, 2024

I've been digging a bit, and I think we went with this format because it is the format used in the examples originally provided by the product team here https://docs.google.com/document/d/1Xn6AazKkpUy85VUaj9v_utasexk8lIqP_1zveILq1So/edit

The format there includes seconds as well, but I remember discussing we didn't need that much precision and we left it at 2023-08-27 23:12.

@acelaya
Copy link
Contributor Author

acelaya commented Oct 3, 2024

Oh, I found this other PR where this function was implemented #6078

It mentions not only the fact that those dates can be sorted, but also that they are detected as "date" by most common spreadsheet editors.

I'll add that to the function comment as well.

@acelaya acelaya force-pushed the frontend-shared-dates branch 3 times, most recently from 2d16ab9 to 4542c6a Compare October 3, 2024 09:01
Copy link
Member

@robertknight robertknight left a comment

Choose a reason for hiding this comment

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

LGTM with some small requested changes.

src/sidebar/util/time.ts Outdated Show resolved Hide resolved
src/sidebar/util/time.ts Outdated Show resolved Hide resolved
src/sidebar/util/time.ts Show resolved Hide resolved
@acelaya acelaya merged commit 88d7875 into main Oct 4, 2024
4 checks passed
@acelaya acelaya deleted the frontend-shared-dates branch October 4, 2024 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants