Bug 452236 - normalizeExpression output on monthday_range is simplified
Summary: normalizeExpression output on monthday_range is simplified
Status: RESOLVED FIXED
Alias: None
Product: KOpeningHours
Classification: Applications
Component: normalization (other bugs)
Version First Reported In: 21.12.3
Platform: unspecified All
: NOR normal
Target Milestone: ---
Assignee: David Faure
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-04-03 18:55 UTC by fam.lam
Modified: 2024-04-13 08:48 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description fam.lam 2022-04-03 18:55:30 UTC
From https://github.com/osm-fr/osmose-backend/pull/1424#issuecomment-1086725579

STEPS TO REPRODUCE
1. call normalizedExpression() on "2099 May 22-2099 Oct 07"

OBSERVED RESULT
normalizedExpression() produces "2099 May 22-Oct 07"

EXPECTED RESULT
No change for normalizedExpression, i.e. output equals input
Per https://wiki.openstreetmap.org/wiki/Key:opening_hours/specification#selector:month , 
<monthday_range> gives <date_from> [ <date_offset> ] - <date_to> [ <date_offset> ], 
<date_from> and <date_to> are defined as (a.o.) [ <year> ] <month> <daynum>

Unrelated, but for simplifiedExpression() the output is expected to be simplified to 2099 May 22-Oct 07
Comment 1 fam.lam 2022-04-16 13:17:05 UTC
Actually when I look at the opening hours specification (https://wiki.openstreetmap.org/wiki/Key:opening_hours/specification) I start to wonder if 
> 2022 Mar 31 - Apr 16
is really the same as 
> 2022 Mar 31 - 2022 Apr 16

2022 Mar-Apr is valid per [ <year> ] <month> - <month>	
2022 Mar 31 - 2022 Apr 16 is valid per <date_from> [ <date_offset> ] - <date_to> [ <date_offset> ]

However, no-where in the specs it mentions how "2022 Mar 31 - Apr 16" should be parsed. So I could argue that this selector would also be valid on 2023 Jan 01 until 2023 Apr 16, 2024 Jan 01 until 2024 Apr 16, ..., in contrast to 2022 Mar 31 - 2022 Apr 16 (which is restricted tot the 2022 date range only)
Comment 2 fam.lam 2022-04-20 17:42:35 UTC
In addition, I noticed that also "Jan 01-Jan 31" is changed to "Jan 01-31" in normalizedExpression(). (This is valid, no doubt about that, but it would be great if this was only done at simplifiedExpression)
Comment 3 fam.lam 2024-01-15 23:10:25 UTC
(In reply to fam.lam from comment #1)

Please ignore comment 1, it is clearly wrong (can't find how to delete it though). The original description and comment 2 are still correct.
Comment 4 fam.lam 2024-01-17 22:17:06 UTC
Oh dang, my comment 1 is still correct, I wasn't thinking properly.
The opening hours specification doesn't say that the same year should be assumed if <date_from> contains a year, but <date_to> doesn't contain a year.
Comment 5 David Faure 2024-01-20 17:07:34 UTC
Git commit 497444553d267b830494f0381b7f820a46a3b2bc by David Faure, on behalf of Fam Lam.
Committed on 20/01/2024 at 17:59.
Pushed by dfaure into branch 'master'.

Keep year if months differ with day (undefined behaviour)

M  +4    -0    autotests/parsertest.cpp
M  +1    -1    src/lib/selectors.cpp

https://invent.kde.org/libraries/kopeninghours/-/commit/497444553d267b830494f0381b7f820a46a3b2bc
Comment 6 Volker Krause 2024-04-13 08:48:39 UTC
Git commit bc12a820326f564e00c6533008e027b321fa6644 by Volker Krause, on behalf of Fam Lam.
Committed on 13/04/2024 at 08:46.
Pushed by vkrause into branch 'release/24.02'.

Keep year if months differ with day (undefined behaviour)


(cherry picked from commit 497444553d267b830494f0381b7f820a46a3b2bc)

M  +4    -0    autotests/parsertest.cpp
M  +1    -1    src/lib/selectors.cpp

https://invent.kde.org/libraries/kopeninghours/-/commit/bc12a820326f564e00c6533008e027b321fa6644