Priority: Not Evaluated
Affects Version/s: None
Fix Version/s: None
Component/s: Core: Date/Time
In my application, I am showing and comparing the age of certain historical events. The users should be able to read: "The king was assassinated 108 years, 9 months and two days ago". And also some sentences in these lines: "The twins died 5 years apart"...
All the dates are manipulated and stored (in a MariaDB database) using QDate class.
It would be very nice to have the means to calculate the difference between two points in the calendar, resulting in a human-readable form. It quickly gets tricky when dealing with multiple calendar systems. I would very much like QDate objects to have an operator- implemented which either:
- Returns an instance of a new object (QTimePeriod? QDatePeriod?)
- Or, returns a tuple of three numbers (QCalendar::YearMonthDay)
The latter option is suboptimal for two reasons. First, because the concept of the time period is calendar-specific. That is two years in the Islamic Civil calendar are about 20 days shorter than two years in the Gregorian calendar, for example. Second is that the time periods in a calendar system need an origin to form a vector space. That is, for example, "two months"; if added to February 1st, 2019, is a different time period than if added to September 1st, 2019. Thus we need to define the starting date to be able to uniquely identify a time period. (Maybe to arithmetically compare them, or to convert them to a "durations"?)
So we could have:
This could be extended to QDateTime or QTime as well.
Please note that a date difference is a different concept compared to a duration.