| abian created this task. abian added projects: Wikibase-Quality-Constraints, Wikibase-Quality. Herald added a subscriber: Aklapper. Herald added a project: Wikidata. |
Right now, some violations of the diff-within-range constraint aren't such, they are wrongly calculated. Some examples of the expected functioning of this constraint are given below.
Minimum and maximum differences
When we have two dates in the same calendar, their maximum and minimum differences should be calculated first.
The minimum difference, mindiff, should be calculated as in these examples:
- year 1990 - 20th century = 0, because the year 1990 belongs to the 20th century
- 20th century - year 1920 = 0, because the year 1920 belongs to the 20th century
- 2nd millennium - 1st millennium = 0, the difference between the first moment of the 2nd millennium (1001-01-01 00:00:00) and the last moment of the 1st millennium (1000-12-31 23:59:59.99... = 1001-01-01 00:00:00)
- year 1920 - 19th century = 19 years, the difference between the first moment of the year 1920 (1920-01-01 00:00:00) and the last moment of the 19th century (1900-12-31 23:59:59.99... = 1901-01-01 00:00:00)
- 21st century - year 1920 = 80 years, the difference between the first moment of the 21st century (2001-01-01 00:00:00) and the last moment of the year 1920 (1920-12-31 23:59:59.99... = 1921-01-01 00:00:00)
- year 1990 - year 1810 = 179 years, the difference between the first moment of the year 1990 (1990-01-01 00:00:00) and the last moment of the year 1810 (1810-12-31 23:59:59.99... = 1811-01-01 00:00:00)
The maximum difference, maxdiff, should be calculated as in these examples:
- year 1990 - 20th century = 90 years, the difference between the last moment of the year 1990 (1990-12-31 23:59:59.99... = 1991-01-01 00:00:00) and the first moment of the 20th century (1901-01-01 00:00:00)
- 20th century - year 1920 = 81 years, the difference between the last moment of the 20th century (2000-12-31 23:59:59.99... = 2001-01-01 00:00:00) and the first moment of the year 1920 (1920-01-01 00:00:00)
- 2nd millennium - 1st millennium = 2000 years, the difference between the last moment of the 2nd millennium (2000-12-31 23:59:59.99... = 2001-01-01 00:00:00) and the first moment of the 1st millennium (1-01-01 00:00:00)
- year 1920 - 19th century = 120 years, the difference between the last moment of the year 1920 (1920-12-31 23:59:59.99... = 1921-01-01 00:00:00) and the first moment of the 19th century (1801-01-01 00:00:00)
- 21st century - year 1920 = 181 years, the difference between the last moment of the 21st century (2100-12-31 23:59:59.99... = 2101-01-01 00:00:00) and the first moment of the year 1920 (1920-01-01 00:00:00)
- year 1990 - year 1810 = 181 years, the difference between the last moment of the year 1990 (1990-12-31 23:59:59.99... = 1991-01-01 00:00:00) and the first moment of the year 1810 (1810-01-01 00:00:00)
Intervals
We say there is a violation of the diff-within-range constraint if, and only if, the difference interval [mindiff, maxdiff] and the required diff-within-range interval [P2313, P2312] do not intersect (that is to say, their intersection is empty; in Boolean logic, mindiff > P2312 or P2313 > maxdiff). For the previous examples, if [P2313, P2312] = [0, 150 years], then:
- [0, 90 years] ∩ [0, 150 years] = [0, 90 years] ≠ ∅, so no violation.
- [0, 81 years] ∩ [0, 150 years] = [0, 81 years] ≠ ∅, so no violation.
- [0, 2000 years] ∩ [0, 150 years] = [0, 150 years] ≠ ∅, so no violation.
- [19 years, 120 years] ∩ [0, 150 years] = [19, 120 years] ≠ ∅, so no violation.
- [80 years, 181 years] ∩ [0, 150 years] = [80, 150 years] ≠ ∅, so no violation.
- [179 years, 181 years] ∩ [0, 150 years] = ∅, violation!
The implementation should be fixed accordingly.
Cc: abian, Aklapper, Lahi, Gq86, Lucas_Werkmeister_WMDE, GoranSMilovanovic, QZanden, LawExplorer, Agabi10, Wikidata-bugs, aude, Mbch331
_______________________________________________ Wikidata-bugs mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs
