Skip to content

Conversation

reosarevok
Copy link
Member

@reosarevok reosarevok commented Apr 27, 2022

Implement MBS-12230 / MBS-12342 / MBS-12229 / MBS-12341

A mostly straightforward basic implementation of the paste-a-date concept. This first PR only supports basic straightforward cases where there is no possible clash (YYYY-MM-DD, both Western and East Asian). We can add support for other date strings that do require user choices (such as DD/MM/YYYY vs MM/DD/YYYY, where the user needs to pick what they meant for a date such as "01/02/2020") in a second PR once we know the basic concept works fine.

Testing

This adds a fair amount of tests for the parsing functions.

@reosarevok reosarevok added the New feature Non urgent new stuff label Apr 27, 2022
@reosarevok reosarevok marked this pull request as ready for review April 28, 2022 17:35
@reosarevok reosarevok force-pushed the MBS-12230 branch 3 times, most recently from 8a52ecc to 87f6338 Compare February 8, 2023 15:17
@reosarevok reosarevok force-pushed the MBS-12230 branch 2 times, most recently from 84b777a to 116e943 Compare December 5, 2023 21:18
Copy link
Member

@mwiencek mwiencek 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 very useful and seems to work well.

When the fields are initially loaded, or when you modify any of the year, month, or day fields, I was wondering if we should

  • update the paste-a-date field with the new formatted date (in ISO format), to provide an easy way to copy existing dates, and
  • enable the HTML autocomplete attribute on the paste-a-date field so that it shows a dropdown of previous dates you've entered, for quick access.

@reosarevok
Copy link
Member Author

Hmm. The first one seems like a no-brainer, and I wish I would have thought of it! The second might be annoying at times, but also probably useful at times... maybe worth a shot if it's not complicated (which I guess it should not be).

@mwiencek
Copy link
Member

mwiencek commented Dec 7, 2023

The second might be annoying at times, but also probably useful at times... maybe worth a shot if it's not complicated (which I guess it should not be).

True...at least in Firefox you can delete individual autofill entries with shift+delete (on macOS).Doesn't seem to work in Chrome anymore, though...

@reosarevok reosarevok force-pushed the MBS-12230 branch 2 times, most recently from f42bc3d to 96a9c19 Compare December 21, 2023 09:08
@reosarevok
Copy link
Member Author

reosarevok commented Dec 21, 2023

To update the paste-a-date field with the new formatted date, I guess we would need the paste-a-date field to be part of the state, which it doesn't seem to be right now, right? Possibly a stupid question but, would that trigger a new set-date because the paste-a-date field changed? If so I guess we'd need a way to stop that to avoid silly loops.

Copy link
Contributor

@julian45 julian45 left a comment

Choose a reason for hiding this comment

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

The link in this commit message is dead; after some browsing in the Internet Archive, I found that they deprecated this site as of 5/31/22. I was able to find some copies of the page earlier than that date, though. Could we maybe use an IA link instead? Such as http://web.archive.org/web/20220330023649/https://reference.discogs.com/wiki/japanese-release-dates

@julian45
Copy link
Contributor

Sorry, that was about 5f1d632 specifically.

@julian45
Copy link
Contributor

julian45 commented Nov 25, 2024

For the record, since Discogs has no sourcing for the special date formatting in question, I'm not as sure there is a need for MB to support it, especially since it's not mentioned in the current edition of RIS 204 (even as a backwards compatibility note or anything like that). I'm having a bit of trouble finding images in MB and Discogs that substantiate this formatting type being a thing, but maybe I just haven't come across the right releases yet.

@julian45
Copy link
Contributor

julian45 commented Dec 3, 2024

I was able to find at least one release with proof of the special Japanese date formatting; see the back cover art here. so I guess it's good to know that this was, in fact, used on real releases. I'd still like to find better standards documentation at some point, but that's definitely not blocking for this PR.

@julian45 julian45 dismissed their stale review December 3, 2024 17:44

About to be made mostly redundant.

@mwiencek
Copy link
Member

mwiencek commented Aug 1, 2025

To update the paste-a-date field with the new formatted date, I guess we would need the paste-a-date field to be part of the state, which it doesn't seem to be right now, right? Possibly a stupid question but, would that trigger a new set-date because the paste-a-date field changed? If so I guess we'd need a way to stop that to avoid silly loops.

Yes, it would need to be part of state too. set-date only triggers when you dispatch it (e.g., from an event handler). Updating the formatted date in the reducer isn't by itself going to trigger any recursive state updates (it's not like knockout observables), unless you are calling set-date again in an effect or something.

@reosarevok reosarevok force-pushed the MBS-12230 branch 3 times, most recently from 834dff5 to 10eba6d Compare August 7, 2025 18:34
@reosarevok reosarevok force-pushed the MBS-12230 branch 2 times, most recently from 493036b to b97525e Compare August 8, 2025 08:57
@reosarevok reosarevok changed the title MBS-12230: Allow pasting / parsing dates on date fields MBS-12230 / MBS-12342 / MBS-12229 / MBS-12341: Allow pasting / parsing dates on date fields Aug 8, 2025
@reosarevok reosarevok requested a review from mwiencek August 27, 2025 09:08
Copy link
Member

@mwiencek mwiencek left a comment

Choose a reason for hiding this comment

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

A couple issues I've noted after quickly testing:

  • The date parser fields are missing from the artist form.
  • Entering YYYY=1999, MM=(no value), DD=09 in the date fields correctly renders 1999-??-09 in the parser field, but pasting 1999-??-09 in the parser parses it as YYYY=1999, MM=09 instead of YYYY=1999, DD=09.

As a first step, this supports only YMD dates.
Further options can be added in subsequent commits.
The regex is based on the one from the original paste-a-date script.
We generally want to order these as year, month, day.
It's trivial to convert fullwidth numbers (and hypens)
to halfwidth ones, so we might as well support this.
Fullwidth support will be more useful in further commits
once we add proper support for CJK dates.
This adds support for Chinese, Taiwanese, Japanese and Korean dates.
This makes it so that the date parser and the parsed date are kept
in sync, so it is easier to edit and copy the dates.
This adds autocomplete=on to the date parser field, to allow
users to reuse recently used dates more easily.
@reosarevok
Copy link
Member Author

I made a change so that the initial date will be added to the date parser also in TT forms that use HydratedDateRangeFieldset, such as the label form. That said, the artist form is full TT (at least until #3540 gets merged) and as such it cannot really use this just yet.

I'll look at parsing partial dates soon.

This adds support for parsing partial dates (as in, ones without
year or month). They can be entered as ????-01-01 or whatnot
in the parser and that specific part of the date field will be
left empty.

This only works with dates in the standard YYYY-MM-DD format,
with hypens or with spaces.
@reosarevok
Copy link
Member Author

Partial date parsing should also work now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New feature Non urgent new stuff
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants