mb-userscripts icon indicating copy to clipboard operation
mb-userscripts copied to clipboard

More edit date woes

Open ROpdebee opened this issue 3 years ago • 8 comments

https://github.com/ROpdebee/mb-userscripts/commit/655fa671fe10c2fb9844ccf1ac15559e3856f520#commitcomment-49182569

FYI, this warning is shown to me for every single artwork edit with Firefox 87 and Violentmonkey. I had a brief look at the code of get closeDate() but did not found anything why the date detection should not work as expected...

@kellnerd Can you tell me what language and timezone you've set in your MB profile, and what the text says when you hover over the close date? Also, what's the output of e.g. new Date('2021-04-06')?

ROpdebee avatar Apr 06 '21 22:04 ROpdebee

new Date('2021-04-06') gives:

Date Tue Apr 06 2021 02:00:00 GMT+0200 (Central European Summer Time)

So my timezone is UTC+2, the display language (of browser and MB) is English and MB's date/time format (also seen on hover for the closing date) was set to DD.MM.YYYY HH:MM.

Edit: Of course the date format is the culprit, not sure how I have overseen this. After changing it to YYYY-MM-DD, it worked flawlessly.

kellnerd avatar Apr 06 '21 22:04 kellnerd

I hate dates. And there's like 10 different format options. I'll see if I can fix this.

ROpdebee avatar Apr 06 '21 22:04 ROpdebee

Probably not worth the effort for some weirdos like me, who change the display format and expect their userscripts to work nevertheless ;) I think I originally changed it because I did not like the long default format which unnecessarily includes the time zone (which is always the same).

Unfortunately there is no client-side cookie for this setting because all of these messages are rendered server-side, so the easiest solution would be to disable the release event check if the user has configured an "invalid" date format. I could live with that since edits which are adding cover art to unreleased albums are rather rare.

kellnerd avatar Apr 06 '21 22:04 kellnerd

Nah it's not too much effort, it's just a matter of translating window.__MB__.$c.user.preferences.datetime_format into a format that moments.js understands.

Of course, that's yet another dependency, but oh well.

ROpdebee avatar Apr 06 '21 22:04 ROpdebee

Tested this with the most important date format variations and all available languages, parses correctly every time. So it should remain working until some translations are updated, new formats are introduced, or the library breaks. :)

ROpdebee avatar Apr 06 '21 23:04 ROpdebee

As it seems the crossed fingers did not help very long 🙄 Apparently <span class="tooltip" title="20.05.2021 24:05">1 day</span> from Edit #79685050 does trigger the "Cannot determine the closing date of this edit [...]" message because MBS outputs an invalid(?) time format 24:mm which is not supported by Moment.js. Just for your information, not sure whether I should report this as a bug in MBS instead...

kellnerd avatar May 18 '21 15:05 kellnerd

https://chatlogs.metabrainz.org/brainzbot/musicbrainz/msg/4801670/ Ticket concerning the 24:mm bug in MBS: https://tickets.metabrainz.org/browse/MBS-11671 Ticket to close and prevent this once and for all: https://tickets.metabrainz.org/browse/MBS-11672

ROpdebee avatar May 18 '21 18:05 ROpdebee

For future reference: The 24:mm bug should have been fixed in MBS. Still, a more robust solution would be welcome.

ROpdebee avatar Jun 02 '21 19:06 ROpdebee