aboutsummaryrefslogtreecommitdiffstats
path: root/core/time.c
AgeCommit message (Collapse)Author
2020-09-29core: add helper functions to format / parse timestampsGravatar Berthold Stoeger
To save datetime-based filter constraints to git or XML, it is preferrable to use human-readable representations. Therefore, add helper functions to format / parse timestamp_t 64-bit values in the "YYYY-MM-DD hh:mm:ss" format. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-29core: add functions to core/time.cGravatar Berthold Stoeger
To support the new filter code, add helper functions that turn timestamps into year and day-of-week to core/time.c. Internally, these functions simply call utc_mktime() to break down the timestamp and then extract the wanted value. This may appear inefficient, but testing shows that modern compilers are quite effective in throwing away the unneeded calculations. FWIW in this respect clang10 outperformed gcc10. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-01cleanup: move declaration of utc_mk* functions to new subsurface-time.h headerGravatar Berthold Stoeger
No point in slurping in all of dive.h for translation units that only want to do some time manipulation without ever touching a dive. Don't call the header "time.h", because we don't want to end up in a confusion with the system header of the same name. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-04-29Add SPDX header to core C filesGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-17Handle negative dates (before the epoch) betterGravatar Linus Torvalds
The Qt model sorting for the dive date was using a unsigned number, which doesn't work for dates before 1970. Also, the dive date parsing got the year 1900 wrong. Not that we really care, because other parts of date handling will screw up with any date before the year 1904. So if you claim to be diving before 1904, you get basically random behavior. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-04-29Extend time parsing to before 1970Gravatar Linus Torvalds
It turns out that we are starting to have users that have logs that go back that far. It won't be common, but let's get it right anyway. NOTE! With us now supporting dates earlier in 1900, this also makes "utc_mktime()" always add the "1900" to the year field. That way we avoid ever using the fairly ambiguous two-digit shorthand. It didn't use to be all that ambiguous when we knew that any two-digit number less than 70 had to be 2000+. Now that we support going back to earlier in the last centiry, that certainty is eroding. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-04Move subsurface-core to core and qt-mobile to mobile-widgetsGravatar Dirk Hohndel
Having subsurface-core as a directory name really messes with autocomplete and is obviously redundant. Simmilarly, qt-mobile caused an autocomplete conflict and also was inconsistent with the desktop-widget name for the directory containing the "other" UI. And while cleaning up the resulting change in the path name for include files, I decided to clean up those even more to make them consistent overall. This could have been handled in more commits, but since this requires a make clean before the build, it seemed more sensible to do it all in one. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>