-
Notifications
You must be signed in to change notification settings - Fork 37.7k
wallet: Remove Boost from DecodeDumpTime #17245
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
Conversation
The function to format a ISO8601 datetime is called
|
Great :) I actually looked for a header to include this so I won't need to do manual declaration in the test. I'll rename it and move it to time.h/cpp |
Yes, that'd make sense! Could also do some roundtrip tests then. I'm a bit concerned about using
Such an explicit warning makes me feel bad. Seems sure this is going to cause builder complaints on some obscure or less obscure platform (does this exist on Android ?). It might be worse than just relying on boost. I wonder if we can find an alternative to this. The old code did: return (ptime - epoch).total_seconds(); Doesn't the same trick exist for C++11 time manipulation? Edit: weird! travis failure looks like |
I'll need to check if Android has it. I'm pretty sure glibc had it for a while so anything glibc should be fine. But I'll look into it when I'm on my laptop again.
Not that I could find. I'll try to look more. But maybe we better off leaving it with boost for now (and coming back to it when we're actually ready to get rid of boost once and for all)
That's just weird. So before gcc5 they didn't fully support c++11? |
That would be a license violation (LGPL is not compatible with MIT). We could use or copy from some other library which is MIT-compatibly-licensed. But yes, probably not worth it as long as it's still using boost for so many other things.
Apparently! |
FWIU the boost trick is just because boost's time isn't unix time. So if you want to get the time since unix epoch you need to subtract unix time 0 from your time. |
Yeah it seems like timezones stuff will only get in in C++20. There's also |
FWIW |
Right. forgot about that. (I see that |
Yes, it always looks like that. But to be honest I think it's better to revisit this later. Likely, at the time that we're really ready to get rid of boost,
|
Yeah :/ I guess we'll leave this for a while and I'll move on :) |
I guess the rename can be done today. I wasn't aware that this util forms a round trip with |
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
Yes, doing the rename/move separately might be worthwhile. maybe instead of getting rid of boost dep, new goal should be "isolate boost usage to a few places that we know are pain points" (such as date/time/sleep/filesystem handling) |
Opened #17266 |
e7b02b5 Add roundtrip and more tests to ParseISO8601DateTime and FormatISO8601DateTime (Elichai Turkel) 9e2c623 Rename DecodeDumpTime to ParseISO8601DateTime and move to time.cpp (Elichai Turkel) Pull request description: As discussed in bitcoin#17245. 1. Renamed the function. 2. Moved it from `rpcdump.cpp` to `time.cpp`. 3. Added a check if the time is less then epoch return 0 to prevent an overflow. 4. Added more edge cases tests and a roundtrip test. ACKs for top commit: laanwj: ACK e7b02b5 MarcoFalke: ACK e7b02b5 promag: Code review ACK e7b02b5. Moved code is correct, left a comment regarding the test change. Tree-SHA512: 703c21e09b2aabc992235149e67acba63d9d77a593ec8f6d2fec3eb63a7e5c406d56cbce6c6513ab32fba43367d073d2345f3b589843e3c5fe4f55ea3e00bf29
Now that #21110 has been merged I think it might be time to resurrect this PR :) Context: #21110 (comment) |
Maybe use https://en.cppreference.com/w/cpp/chrono/parse (C++20)? |
Utilizing C++11 and platform specific function(timegm) to replace the usage of boost in converting a timestamp in string to a unix epoch.
Moved the old function to the unit tests to check for consistency (in case there's some corner case in timezones)
Sadly C++11 doesn't have anything to handle timezones currently(C++20 seems to have heh) so I had to use
timegm
from POSIX and_mkgmtime
from windows.Tested on linux only.