![]() This is a duplicate of the changes from commit with same subject line in GothenburgBitFactory/libshared#81 and also duplicates the commit message below. Timewarrior has copies of many functions from libshared's Datetime class in its own DatetimeParser class, and until such time as these classes are integrated, we have to maintain copies of these functions here, and the changes need to be duplicated. See discussion in aforementioned PR. The one difference with the patch over there is, this one is using the public Datetime::dayOfWeek() and Datetime::daysInYear() methods from libshared, rather than its own implementation. The copy in Timewarrior already was doing this before, but it's worth noting it's the only difference with the corresponding patch in libshared PR 81, and only amounts to a change in the namespace qualifier. Copied commit message from libshared follows. * * * This patch makes the parsing of week numbers in dates ISO-8601 compliant in the case that Datetime::weekstart == 1, while the existing behavior remains available if Datetime::weekstart == 0. The previous code parsed week numbers (given as "yyyy-Www") into dates starting on Sunday. Although the code had a "Datetime::weekstart" variable, and this value was initialized to 1 (which is Monday) in libshared, nonetheless week specifications would be parsed into calendar days starting on Sunday. Furthermore, week days in such given weeks ('d' in "yyyy-Www-d") used 0-6 for Sunday-Monday, while ISO8601 specifies 1-7 Monday-Sunday. Therefore, yyyy-Www-0 was treated as valid (and should not be), while yyyy-Www-7 was invalid (and should be valid). Note that neither Taskwarrior nor Timewarrior ever set the value of Datetime::weekstart. Taskwarrior has an rc.weekstart, but this is only used for "task calendar" output, not for parsing dates. The patch does the following: - Initialize "Datetime" instances with a weekday value from Datetime::weekstart. This helps the case when weekday is not supplied, it won't default to zero and fail validation (when weekstart is '1'). Note that mktime() is usually used in the code to convert populated "struct tm" broken-down times into epoch-times, and this operation does not use tm.tm_wday for input, only as an output field, recomputed as a normalized value, so it appears to be safe to initialize it with a 1 (which we might wonder about since .tm_wday is supposed to be 0-6 Sunday based). - Use the already-existing Datetime::parse_weekday() to parse the 'ww' in "yyyy-Www" input dates (the function was not used by any caller previously; guessing it may have been intended for eventual use in order to respect weekstart(?)) - Teach parse_weekday() about weekstart. Previously this assumed 1-7, which is the reason I'm guessing this was intended to be used for ISO weeks eventually. Now it can also use 0-6 if weekstart 0. - Teach Datetime::validate to respect Datetime::weekstart also. Previously only 0-6 Sunday-Monday was considered valid. - Default the weekday to Datetime::weekstart if not supplied, ie for "yyyy-Www-X" if the "-X" is not supplied, as recognized when Datetime::standaloneDateEnabled = true, which is the case for (1) tests, (2) timewarrior, but NOT for taskwarrior at this time (both the standalone 'calc' and 'task calc' (ie Context.cpp) set this to false). - Implement the complete ISO week calculation algorithm in Datetime::resolve() if weekstart is '1', and keeps the existing algorithm if weekstart is '0'. This will allow Taskwarrior and Timewarrior to offer the option of the old behavior for those who want to use Sunday-based weeks and ignore ISO week calculations (such as 2023-01-01 being in ISO week 2022-W52). Signed-off-by: Scott Mcdermott <scott@smemsh.net> |
||
---|---|---|
.github | ||
cmake | ||
completion | ||
doc | ||
docker | ||
ext | ||
src | ||
test | ||
.gitignore | ||
.gitmodules | ||
.pre-commit-config.yaml | ||
AUTHORS | ||
ChangeLog | ||
cmake.h.in | ||
CMakeLists.txt | ||
commit.h.in | ||
CONTRIBUTING.md | ||
DCO | ||
docker-compose.yml | ||
INSTALL | ||
LICENSE | ||
README.md |
Timewarrior
Thank you for taking a look at Timewarrior!
Timewarrior is a time tracking utility that offers simple stopwatch features as well as sophisticated calendar-based backfill, along with flexible reporting. It is a portable, well-supported and very active Open Source project.
Please visit timewarrior.net for extensive documentation, downloads, news and more.
Installing
From Package
Thanks to the community, there are binary packages available here.
Building Timewarrior
Building Timewarrior yourself requires
- Git
- CMake (>= 3.8)
- Make
- C++ compiler with full C++17 support, currently GCC 8+ or Clang 5+
- Python 3 (for running the testsuite)
- Asciidoctor (for creating documentation)
There are two ways to retrieve the Timewarrior sources:
- Clone the repository from GitHub and update required submodules,
git clone --recurse-submodules https://github.com/GothenburgBitFactory/timewarrior cd timewarrior
- Or download the tarball with curl,
and expand the tarballcurl -O https://github.com/GothenburgBitFactory/timewarrior/releases/download/v1.7.1/timew-1.7.1.tar.gz
tar xzf timew-1.7.1.tar.gz cd timew-1.7.1
Build Timewarrior, optionally run the test suite, and install it.
cmake -DCMAKE_BUILD_TYPE=release .
make
[make test]
sudo make install
This copies files into the right place (default under /usr/local
), and installs man pages.
Add the optional parameter -DCMAKE_INSTALL_PREFIX=/path/to/your/install/location
to the cmake
command if you want to install Timewarrior at a location other than /usr/local
.
The make install
command may not require sudo
depending on your choice of install location.
Community
Timewarrior has a lively community on many places on the internet. The project has its own Twitter account, and shares community spaces on IRC and Discord with Taskwarrior.
Best place to ask questions is our discussions forum on GitHub. For other support options, take a look at timewarrior.net/support
Contributing
Contributions are greatly appreciated. Whether in the form of code patches, ideas, discussion, bug reports, encouragement or criticism, we need you!
For support options, take a look at CONTRIBUTING.md or visit timewarior.net.
Visit GitHub and participate in the future of Timewarrior.
License
Timewarrior is released under the MIT license. For details check the LICENSE file.