-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CDateTime: use std::chrono and std::date libraries #18727
base: master
Are you sure you want to change the base?
Conversation
I am now evaluating the possibility to ise |
What I need now is maximal testing on OSX, FreeBSD, Android and non-Debian Linux. The To make sure I did not miss anything, testing is a must. |
Something that is for sure busted is the date entry dialogs. You can test this by creating a new smart playlist, adding a rule for date created and try to set a date. (EDIT: the code in question is here -> https://github.com/xbmc/xbmc/blob/master/xbmc/dialogs/GUIDialogNumeric.cpp) I'm not sure what @DaveTBlake thinks but I would think this might be too risky (and too late) for v19. |
This also won't work on windows as that platform doesn't use the normal depends build system. We would have to get @Paxxi to compile the date lib for windows so it can be added to the build. |
Since CDateTime is so fundamental and has broad impact this does seem risky for the timescales we want to push for the release of v19. So please continue to pursue this work @basilgello , but be prepared for it not to merge into v19. Despite the code not being directly touched, from previous experience changes to datetime can trigger the entire music library to be rescanned on the next library update (can be a slow process on a large library). This is because datetime is used in the formation of hash values used it the folder/file checking process. So can some testing include having a previously populated music library please. |
The digest changes so a scan will be forced, see: https://github.com/xbmc/xbmc/pull/18727/files#diff-b9394f09c93c1f12392dcc243a628ecdc2d228671f58d45d14ab2d1175b3d8f3R1250 |
Now I see what you mean, thanks! Will fix it in the next few days.
Isn't the proper solution here to increase database version and create a migration wrapper function (maybe, keeping one or two functions from the old |
375d729
to
1ac2cdc
Compare
1ac2cdc
to
adf30f8
Compare
adf30f8
to
c7b701b
Compare
c7b701b
to
b36e06f
Compare
b36e06f
to
60420eb
Compare
c2620f5
to
f299313
Compare
f299313
to
ae97c4b
Compare
@basilgello did you want to continue with this or did you want me to take it over? |
no, re-scanning isn't a problem, it's just good to be aware that hashes will have to be recalculated because of the size of type change. It's a one time thing that will happen and doesn't really have to do anything with the database. If someone downgrades to a version that doesn't use this PR the hashes will just be recalculated again. |
@basilgello did you want to continue with this or did you want me to take it over?
I did include this in Debian package of v19 since RC1.
So far there is only one unresolved bug with that patch exists in Debian.
I am going to hunt the root cause of that one for v19.1.
As for v20, I think you should take over my changes and I will keep testing / fixing stuff.
We need the DB schema upgrade from @DaveTBlake to resolve the music library issue now.
|
The 'GetAsStringsWithBias' test logic assumed the timezone on machine bullding Kodi is set to 'UTC'. This is not always the case, plus hour value was declared with a typo. To address this, we compare outputs of two runs of date library, and instead add a 'Tzdata' test case comparing local date and time against computed values from different timezones: find /usr/share/zoneinfo/Etc/ -type f | sort -Vu | sed 's,^/usr/share/zoneinfo/,,' | while read TZ do TMSTR=$(LANG=C TZ="$TZ" date '+%Y-%m-%dT%H:%M:%S%Ez' -d "1991-05-14 12:34:56 UTC" | sed 's/[0-9][0-9]$/:&/') echo " // LANG=C TZ=\"$TZ\" date '+%Y-%m-%dT%H:%M:%S%Ez' -d \"1991-05-14 12:34:56 UTC\" | sed 's/[0-9][0-9]$/:&/'" echo " tps = date::floor<std::chrono::seconds>(dateTime.GetAsTimePoint());" echo " zone = date::make_zoned(\"$TZ\", tps);" echo " EXPECT_EQ(date::format(\"%FT%T%Ez\", zone), \"$TMSTR\") << \"tzdata information not valid for '$TZ'\";" echo "" done
The 'm_time' now represents a UTC time-point, so 'GetAsUTCDateTime' does nothing useful. Remove it fully, and add 'GetAsLocalDateTime' function that we will use later to convert UTC (system) time to the local time needed to get displayed in UI. Signed-off-by: Vasyl Gello <vasek.gello@gmail.com>
... from local time by default to UTC time by default. Namely, 'CDateTime::SetFromUTCDateTime' converted the UTC time to local time in the implementation of CDateTime before 'std::chrono'. Now this conversion has gone, and to avoid displaying PVR times in UTC, 'GetAsLocalDateTime' is added where necessary. Signed-off-by: Vasyl Gello <vasek.gello@gmail.com>
* The 'const CDateTime& CPVRRecording::RecordingTimeAsLocalTime() const' method needs 'static' CDateTime instance set explicitly. This manifested in Debian Bug #980038 : the return value of function is explicitly nulled out causing immediate crash when using any PVR addon manipulating PVR recordings. Signed-off-by: Vasyl Gello <vasek.gello@gmail.com>
Fixes pvr.dvbviewer#49 Closes: #984682 Signed-off-by: Vasyl Gello <vasek.gello@gmail.com>
Signed-off-by: Vasyl Gello <vasek.gello@gmail.com>
This should fix the GUI date dialog issue: xbmc#18727 (comment) xbmc#18727 (comment) Signed-off-by: Vasyl Gello <vasek.gello@gmail.com>
Signed-off-by: Vasyl Gello <vasek.gello@gmail.com>
This should leave the possibility of time_t truncation on 32-bit architectures only in GetAsTime(), what we can do nothing with. Signed-off-by: Vasyl Gello <vasek.gello@gmail.com>
Fixes broken timezone picker as reported in Debian Bug#1011294. Also fixes TZ-related issue spotted on reproducibility build where TZ envvar specifying timezone as absolute pathname on Linux and FreeBSD screwed date lib up. Signed-off-by: Vasyl Gello <vasek.gello@gmail.com>
* Apply clang-format fixes on CDateTime * Drop unused "persistence" variable from Scraper Signed-off-by: Vasyl Gello <vasek.gello@gmail.com>
Signed-off-by: Vasyl Gello <vasek.gello@gmail.com>
8e5017f
to
b0f2d8e
Compare
@basilgello using floating point data types for time points and time spans has lots of implications, so I'd rather not go down that route. is it really necessary? we have been fine with integers so far, so I guess there must be some way to stay with that? I have to say though that I didn't read the 300+ comments this PR already has, so I hope you forgive me if this was already discussed. |
Rationale about doing this: #18727 (comment) I have this code basically since 2021 in Debian and no user ever complained in Bullseye, Bookworm and now Trixie. |
If you insist on integer type AND nanosecond precision, we can use something like https://github.com/int128-libraries/curtint128 to enable 128-bit integers even on 32-bit architectures. GCC14 supports them out of the box on 64-bit architectures only. |
Thanks for providing the context. I don't see any reason why we should need nanosecond precision though (in general as well as in the linked comments)? We didn't have it before as well, after all. Python datetime (which I guess most addons use) is also "limited" to microseconds. This is also only about the default handling in So I'd definitely throw my vote in the "microseconds as 64-bit integer" basket :-) |
TBH I also dont recall why I decided we need ns resolution - I should have noted this somewhere. From the quick search over this repo we use nanoseconds in Starfish codec (audio and video), in Neptune UPnP (but not datetime yet!) and |
So wouldn't the safest choice be to replicate FILETIME with the 100 ns resolution? Or does this create other problems? |
I did not test but 100ns resolution is easy doable - you need to multiply or divide a factor of 10 to get ms to filetime-ish conversion. |
Then I think defining the "standard" (i.e., what is used for CDateTime) to 100 ns resolution would be the preferred solution from my side 👌 it has sufficient accuracy for the usual operations with dates and will likely cause the least problems in transition |
Just in case this helps: using Duration = std::chrono::duration<std::int64_t, std::ratio<1, 10'000'000>>;
using TimePoint = std::chrono::time_point<std::chrono::system_clock, Duration>; |
Description
Rework
CDateTime
core component using C++ libraries.Motivation and Context
This is a continuation of @lrusak
cdatetime-std-chrono
topic. I would like to have it merged in v19 because it fixes Debian builds on i386 (it still does NOT address Y2038 problem, but the discussion with colleagues in Debian Multimedia Team revealed that it is not necessary at this point).How Has This Been Tested?
Types of change
Checklist: