diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..aa436239 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 2 + +[**/man/**] +insert_final_newline = false diff --git a/AUTHORS b/AUTHORS index 09a8cc7f..7f3b4f65 100644 --- a/AUTHORS +++ b/AUTHORS @@ -71,3 +71,4 @@ Thanks to the following, who submitted detailed bug reports and excellent sugges sclo ddombrowsky triclops200 + Valodim diff --git a/ChangeLog b/ChangeLog index e7303bf8..8f809aed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -37,6 +37,8 @@ (thanks to janikrabe) - #174 Interval is split in two when it encloses month border - #183 Hyphen in annotation gets padded with spaces +- #189 segfault on timew get dom.active.tag.0 + (thanks to Valodim) - Fixed error from totals.py while timer is active (thanks to davisdude) - Refactoring of Interval and Range diff --git a/README-Template.md b/README-Template.md new file mode 100644 index 00000000..aec8202d --- /dev/null +++ b/README-Template.md @@ -0,0 +1,88 @@ +# Project Title + +One Paragraph of project description goes here + +## Getting Started + +These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system. + +### Prerequisites + +What things you need to install the software and how to install them + +``` +Give examples +``` + +### Installing + +A step by step series of examples that tell you have to get a development env running + +Say what the step will be + +``` +Give the example +``` + +And repeat + +``` +until finished +``` + +End with an example of getting some data out of the system or using it for a little demo + +## Running the tests + +Explain how to run the automated tests for this system + +### Break down into end to end tests + +Explain what these tests test and why + +``` +Give an example +``` + +### And coding style tests + +Explain what these tests test and why + +``` +Give an example +``` + +## Deployment + +Add additional notes about how to deploy this on a live system + +## Built With + +* [Dropwizard](http://www.dropwizard.io/1.0.2/docs/) - The web framework used +* [Maven](https://maven.apache.org/) - Dependency Management +* [ROME](https://rometools.github.io/rome/) - Used to generate RSS Feeds + +## Contributing + +Please read [CONTRIBUTING.md](https://gist.github.com/PurpleBooth/b24679402957c63ec426) for details on our code of conduct, and the process for submitting pull requests to us. + +## Versioning + +We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/your/project/tags). + +## Authors + +* **Billie Thompson** - *Initial work* - [PurpleBooth](https://github.com/PurpleBooth) + +See also the list of [contributors](https://github.com/your/project/contributors) who participated in this project. + +## License + +This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details + +## Acknowledgments + +* Hat tip to anyone who's code was used +* Inspiration +* etc + diff --git a/TI-103-1.sh b/TI-103-1.sh new file mode 100755 index 00000000..acc66aca --- /dev/null +++ b/TI-103-1.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +TODAY=$(date "+%Y%m%d") +YESTERDAY=$(date -d "yesterday" "+%Y%m%d") +CURRENT_HOUR=$(date +%k) + +function get_current_date_with_delta() +{ + local delta=${1} + + let "hour = CURRENT_HOUR + delta" + + if [[ ${hour} -lt 0 ]] ; then + let "hour = hour + 24" + day=${YESTERDAY} + else + day=${TODAY} + fi + + if [[ ${hour} -lt 10 ]] ; then + hour="0${hour}" + fi + + echo "${day}T${hour}0000" +} + +export TIMEWARRIORDB=/home/lauft/Projects/timew/timewarriordb +rm -f ${TIMEWARRIORDB}/data/*.data +:> ${TIMEWARRIORDB}/timewarrior.cfg + +cat < ${TIMEWARRIORDB}/timewarrior.cfg +exclusions.monday = <9:00 >20:00 +exclusions.tuesday = <9:00 >20:00 +exclusions.wednesday = <9:00 >20:00 +exclusions.thursday = <9:00 >20:00 +exclusions.friday = <9:00 >20:00 +exclusions.saturday = <9:00 >20:00 +exclusions.sunday = <9:00 >20:00 +reports.day.hours = auto +reports.week.hours = auto +reports.month.hours = auto +EOF + +five_hours_before=$(get_current_date_with_delta "-5") +four_hours_before=$(get_current_date_with_delta "-4") +three_hours_before=$(get_current_date_with_delta "-3") +two_hours_before=$(get_current_date_with_delta "-2") +one_hour_before=$(get_current_date_with_delta "-1") +current_hour=$(get_current_date_with_delta "0") +one_hour_after=$(get_current_date_with_delta "1") +two_hours_after=$(get_current_date_with_delta "2") + +src/timew track "${YESTERDAY}T1200" - "${YESTERDAY}T1400" FOO +src/timew start "${YESTERDAY}T1900" BAR +#src/timew week :month + +echo "TI-103-1.sh: open interval from yesterday" diff --git a/TI-103-2.sh b/TI-103-2.sh new file mode 100755 index 00000000..1f8454ab --- /dev/null +++ b/TI-103-2.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +TODAY=$(date "+%Y%m%d") +YESTERDAY=$(date -d "yesterday" "+%Y%m%d") +CURRENT_HOUR=$(date +%k) + +function get_current_date_with_delta() +{ + local delta=${1} + + let "hour = CURRENT_HOUR + delta" + + if [[ ${hour} -lt 0 ]] ; then + let "hour = hour + 24" + day=${YESTERDAY} + else + day=${TODAY} + fi + + if [[ ${hour} -lt 10 ]] ; then + hour="0${hour}" + fi + + echo "${day}T${hour}0000" +} + +export TIMEWARRIORDB=/home/lauft/Projects/timew/timewarriordb +rm -f ${TIMEWARRIORDB}/data/*.data +:> ${TIMEWARRIORDB}/timewarrior.cfg + +cat < ${TIMEWARRIORDB}/timewarrior.cfg +exclusions.monday = <9:00 >20:00 +exclusions.tuesday = <9:00 >20:00 +exclusions.wednesday = <9:00 >20:00 +exclusions.thursday = <9:00 >20:00 +exclusions.friday = <9:00 >20:00 +exclusions.saturday = <9:00 >20:00 +exclusions.sunday = <9:00 >20:00 +reports.day.hours = auto +reports.week.hours = auto +reports.month.hours = auto +EOF + +five_hours_before=$(get_current_date_with_delta "-5") +four_hours_before=$(get_current_date_with_delta "-4") +three_hours_before=$(get_current_date_with_delta "-3") +two_hours_before=$(get_current_date_with_delta "-2") +one_hour_before=$(get_current_date_with_delta "-1") +current_hour=$(get_current_date_with_delta "0") +one_hour_after=$(get_current_date_with_delta "1") +two_hours_after=$(get_current_date_with_delta "2") + +src/timew track "${YESTERDAY}T1200" - "${YESTERDAY}T1400" FOO +src/timew track "${YESTERDAY}T1900" - "${YESTERDAY}T2000" BAR1 +src/timew start "${TODAY}T0900" BAR2 +#src/timew week :month + +echo "TI-103-2.sh: open interval today" diff --git a/TI-103-3.sh b/TI-103-3.sh new file mode 100755 index 00000000..75a0b430 --- /dev/null +++ b/TI-103-3.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +TODAY=$(date "+%Y%m%d") +YESTERDAY=$(date -d "yesterday" "+%Y%m%d") +CURRENT_HOUR=$(date +%k) + +function get_current_date_with_delta() +{ + local delta=${1} + + let "hour = CURRENT_HOUR + delta" + + if [[ ${hour} -lt 0 ]] ; then + let "hour = hour + 24" + day=${YESTERDAY} + else + day=${TODAY} + fi + + if [[ ${hour} -lt 10 ]] ; then + hour="0${hour}" + fi + + echo "${day}T${hour}0000" +} + +export TIMEWARRIORDB=/home/lauft/Projects/timew/timewarriordb +rm -f ${TIMEWARRIORDB}/data/*.data +:> ${TIMEWARRIORDB}/timewarrior.cfg + +cat < ${TIMEWARRIORDB}/timewarrior.cfg +exclusions.monday = <9:00 >20:00 +exclusions.tuesday = <9:00 >20:00 +exclusions.wednesday = <9:00 >20:00 +exclusions.thursday = <9:00 >20:00 +exclusions.friday = <9:00 >20:00 +exclusions.saturday = <9:00 >20:00 +exclusions.sunday = <9:00 >20:00 +reports.day.hours = auto +reports.week.hours = auto +reports.month.hours = auto +EOF + +five_hours_before=$(get_current_date_with_delta "-5") +four_hours_before=$(get_current_date_with_delta "-4") +three_hours_before=$(get_current_date_with_delta "-3") +two_hours_before=$(get_current_date_with_delta "-2") +one_hour_before=$(get_current_date_with_delta "-1") +current_hour=$(get_current_date_with_delta "0") +one_hour_after=$(get_current_date_with_delta "1") +two_hours_after=$(get_current_date_with_delta "2") + +src/timew track "${YESTERDAY}T1200" - "${YESTERDAY}T1400" FOO +#src/timew week :month + +echo "TI-103.sh: no open interval" diff --git a/TI-103-4.sh b/TI-103-4.sh new file mode 100755 index 00000000..9155f611 --- /dev/null +++ b/TI-103-4.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +TODAY=$(date "+%Y%m%d") +YESTERDAY=$(date -d "yesterday" "+%Y%m%d") +CURRENT_HOUR=$(date +%k) + +function get_current_date_with_delta() +{ + local delta=${1} + + let "hour = CURRENT_HOUR + delta" + + if [[ ${hour} -lt 0 ]] ; then + let "hour = hour + 24" + day=${YESTERDAY} + else + day=${TODAY} + fi + + if [[ ${hour} -lt 10 ]] ; then + hour="0${hour}" + fi + + echo "${day}T${hour}0000" +} + +export TIMEWARRIORDB=/home/lauft/Projects/timew/timewarriordb +rm -f ${TIMEWARRIORDB}/data/*.data +:> ${TIMEWARRIORDB}/timewarrior.cfg + +cat < ${TIMEWARRIORDB}/timewarrior.cfg +exclusions.monday = <9:00 >20:00 +exclusions.tuesday = <9:00 >20:00 +exclusions.wednesday = <9:00 >20:00 +exclusions.thursday = <9:00 >20:00 +exclusions.friday = <9:00 >20:00 +exclusions.saturday = <9:00 >20:00 +exclusions.sunday = <9:00 >20:00 +reports.day.hours = auto +reports.week.hours = auto +reports.month.hours = auto +EOF + +five_hours_before=$(get_current_date_with_delta "-5") +four_hours_before=$(get_current_date_with_delta "-4") +three_hours_before=$(get_current_date_with_delta "-3") +two_hours_before=$(get_current_date_with_delta "-2") +one_hour_before=$(get_current_date_with_delta "-1") +current_hour=$(get_current_date_with_delta "0") +one_hour_after=$(get_current_date_with_delta "1") +two_hours_after=$(get_current_date_with_delta "2") + +src/timew track "${YESTERDAY}T1200" - "${YESTERDAY}T1400" FOO +src/timew track "${YESTERDAY}T1900" - "${YESTERDAY}T2000" BAR1 +src/timew track "${TODAY}T0900" - "${TODAY}T1200" BAR2 +#src/timew week :month + +echo "TI-103-4.sh: closed interval today" diff --git a/TI-103-5.sh b/TI-103-5.sh new file mode 100755 index 00000000..0b97c8d7 --- /dev/null +++ b/TI-103-5.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +TODAY=$(date "+%Y%m%d") +YESTERDAY=$(date -d "yesterday" "+%Y%m%d") +CURRENT_HOUR=$(date +%k) + +function get_current_date_with_delta() +{ + local delta=${1} + + let "hour = CURRENT_HOUR + delta" + + if [[ ${hour} -lt 0 ]] ; then + let "hour = hour + 24" + day=${YESTERDAY} + else + day=${TODAY} + fi + + if [[ ${hour} -lt 10 ]] ; then + hour="0${hour}" + fi + + echo "${day}T${hour}0000" +} + +export TIMEWARRIORDB=/home/lauft/Projects/timew/timewarriordb +rm -f ${TIMEWARRIORDB}/data/*.data +:> ${TIMEWARRIORDB}/timewarrior.cfg + +cat < ${TIMEWARRIORDB}/timewarrior.cfg +reports.day.hours = auto +reports.week.hours = auto +reports.month.hours = auto +EOF + +five_hours_before=$(get_current_date_with_delta "-5") +four_hours_before=$(get_current_date_with_delta "-4") +three_hours_before=$(get_current_date_with_delta "-3") +two_hours_before=$(get_current_date_with_delta "-2") +one_hour_before=$(get_current_date_with_delta "-1") +current_hour=$(get_current_date_with_delta "0") +one_hour_after=$(get_current_date_with_delta "1") +two_hours_after=$(get_current_date_with_delta "2") + +src/timew track "${YESTERDAY}T1200" - "${YESTERDAY}T1400" FOO +src/timew track "${YESTERDAY}T1900" - "${YESTERDAY}T2000" BAR1 +src/timew start "${TODAY}T0900" BAR2 +#src/timew week :month + +echo "TI-103-4.sh: open interval today (no exclusions)" diff --git a/TI-11.sh b/TI-11.sh new file mode 100755 index 00000000..5c4a4eb0 --- /dev/null +++ b/TI-11.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +YESTERDAY=$(date -d "yesterday" "+%Y%m%d") + +export TIMEWARRIORDB=/home/lauft/Projects/timew/timewarriordb +rm -f ${TIMEWARRIORDB}/data/*.data +:> ${TIMEWARRIORDB}/timewarrior.cfg + +timew start ${YESTERDAY}T124452Z homework +timew month +timew week +timew day + diff --git a/TI-155.sh b/TI-155.sh new file mode 100755 index 00000000..059a9249 --- /dev/null +++ b/TI-155.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +TODAY=$(date "+%Y%m%d") +YESTERDAY=$(date -d "yesterday" "+%Y%m%d") +CURRENT_HOUR=$(date +%k) + +function get_current_date_with_delta() +{ + local delta=${1} + + let "hour = CURRENT_HOUR + delta" + + if [[ ${hour} -lt 0 ]] ; then + let "hour = hour + 24" + day=${YESTERDAY} + else + day=${TODAY} + fi + + if [[ ${hour} -lt 10 ]] ; then + hour="0${hour}" + fi + + echo "${day}T${hour}0000" +} + +export TIMEWARRIORDB=/mnt/smalldisk/timewarriordb +rm -f ${TIMEWARRIORDB}/data/*.data +:> ${TIMEWARRIORDB}/timewarrior.cfg + +five_hours_before=$(get_current_date_with_delta "-5") +four_hours_before=$(get_current_date_with_delta "-4") +three_hours_before=$(get_current_date_with_delta "-3") +two_hours_before=$(get_current_date_with_delta "-2") +one_hour_before=$(get_current_date_with_delta "-1") +current_hour=$(get_current_date_with_delta "0") +one_hour_after=$(get_current_date_with_delta "1") +two_hours_after=$(get_current_date_with_delta "2") + diff --git a/TI-159-double-quoted-2.sh b/TI-159-double-quoted-2.sh new file mode 100755 index 00000000..dc0399ee --- /dev/null +++ b/TI-159-double-quoted-2.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +TODAY=$(date "+%Y%m%d") +YESTERDAY=$(date -d "yesterday" "+%Y%m%d") +CURRENT_HOUR=$(date +%k) + +function get_current_date_with_delta() +{ + local delta=${1} + + let "hour = CURRENT_HOUR + delta" + + if [[ ${hour} -lt 0 ]] ; then + let "hour = hour + 24" + day=${YESTERDAY} + else + day=${TODAY} + fi + + if [[ ${hour} -lt 10 ]] ; then + hour="0${hour}" + fi + + echo "${day}T${hour}0000" +} + +export TIMEWARRIORDB=/home/lauft/Projects/timew/timewarriordb +rm -f ${TIMEWARRIORDB}/data/*.data +:> ${TIMEWARRIORDB}/timewarrior.cfg + +five_hours_before=$(get_current_date_with_delta "-5") +four_hours_before=$(get_current_date_with_delta "-4") +three_hours_before=$(get_current_date_with_delta "-3") +two_hours_before=$(get_current_date_with_delta "-2") +one_hour_before=$(get_current_date_with_delta "-1") +current_hour=$(get_current_date_with_delta "0") +one_hour_after=$(get_current_date_with_delta "1") +two_hours_after=$(get_current_date_with_delta "2") + +src/timew start 5min ago "Numbers 1 2 3 Somewhere" "\"one-quoted-word\"" +src/timew stop + diff --git a/TI-159-double-quoted.sh b/TI-159-double-quoted.sh new file mode 100755 index 00000000..80024aff --- /dev/null +++ b/TI-159-double-quoted.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +TODAY=$(date "+%Y%m%d") +YESTERDAY=$(date -d "yesterday" "+%Y%m%d") +CURRENT_HOUR=$(date +%k) + +function get_current_date_with_delta() +{ + local delta=${1} + + let "hour = CURRENT_HOUR + delta" + + if [[ ${hour} -lt 0 ]] ; then + let "hour = hour + 24" + day=${YESTERDAY} + else + day=${TODAY} + fi + + if [[ ${hour} -lt 10 ]] ; then + hour="0${hour}" + fi + + echo "${day}T${hour}0000" +} + +export TIMEWARRIORDB=/home/lauft/Projects/timew/timewarriordb +rm -f ${TIMEWARRIORDB}/data/*.data +:> ${TIMEWARRIORDB}/timewarrior.cfg + +five_hours_before=$(get_current_date_with_delta "-5") +four_hours_before=$(get_current_date_with_delta "-4") +three_hours_before=$(get_current_date_with_delta "-3") +two_hours_before=$(get_current_date_with_delta "-2") +one_hour_before=$(get_current_date_with_delta "-1") +current_hour=$(get_current_date_with_delta "0") +one_hour_after=$(get_current_date_with_delta "1") +two_hours_after=$(get_current_date_with_delta "2") + +src/timew start 5min ago "Numbers 1 2 3 Somewhere" "'one-quoted-word'" +src/timew stop + diff --git a/TI-159-single-quoted-2.sh b/TI-159-single-quoted-2.sh new file mode 100755 index 00000000..df611f76 --- /dev/null +++ b/TI-159-single-quoted-2.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +TODAY=$(date "+%Y%m%d") +YESTERDAY=$(date -d "yesterday" "+%Y%m%d") +CURRENT_HOUR=$(date +%k) + +function get_current_date_with_delta() +{ + local delta=${1} + + let "hour = CURRENT_HOUR + delta" + + if [[ ${hour} -lt 0 ]] ; then + let "hour = hour + 24" + day=${YESTERDAY} + else + day=${TODAY} + fi + + if [[ ${hour} -lt 10 ]] ; then + hour="0${hour}" + fi + + echo "${day}T${hour}0000" +} + +export TIMEWARRIORDB=/home/lauft/Projects/timew/timewarriordb +rm -f ${TIMEWARRIORDB}/data/*.data +:> ${TIMEWARRIORDB}/timewarrior.cfg + +five_hours_before=$(get_current_date_with_delta "-5") +four_hours_before=$(get_current_date_with_delta "-4") +three_hours_before=$(get_current_date_with_delta "-3") +two_hours_before=$(get_current_date_with_delta "-2") +one_hour_before=$(get_current_date_with_delta "-1") +current_hour=$(get_current_date_with_delta "0") +one_hour_after=$(get_current_date_with_delta "1") +two_hours_after=$(get_current_date_with_delta "2") + +src/timew start 5min ago 'foo' '\"quoted words\"' +#src/timew stop :debug + diff --git a/TI-159-single-quoted.sh b/TI-159-single-quoted.sh new file mode 100755 index 00000000..2204a9dc --- /dev/null +++ b/TI-159-single-quoted.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +TODAY=$(date "+%Y%m%d") +YESTERDAY=$(date -d "yesterday" "+%Y%m%d") +CURRENT_HOUR=$(date +%k) + +function get_current_date_with_delta() +{ + local delta=${1} + + let "hour = CURRENT_HOUR + delta" + + if [[ ${hour} -lt 0 ]] ; then + let "hour = hour + 24" + day=${YESTERDAY} + else + day=${TODAY} + fi + + if [[ ${hour} -lt 10 ]] ; then + hour="0${hour}" + fi + + echo "${day}T${hour}0000" +} + +export TIMEWARRIORDB=/home/lauft/Projects/timew/timewarriordb +rm -f ${TIMEWARRIORDB}/data/*.data +:> ${TIMEWARRIORDB}/timewarrior.cfg + +five_hours_before=$(get_current_date_with_delta "-5") +four_hours_before=$(get_current_date_with_delta "-4") +three_hours_before=$(get_current_date_with_delta "-3") +two_hours_before=$(get_current_date_with_delta "-2") +one_hour_before=$(get_current_date_with_delta "-1") +current_hour=$(get_current_date_with_delta "0") +one_hour_after=$(get_current_date_with_delta "1") +two_hours_after=$(get_current_date_with_delta "2") + +src/timew start 5min ago 'Numbers 1 2 3 Somewhere' '"one-quoted-word"' +src/timew stop + diff --git a/TI-170.sh b/TI-170.sh new file mode 100755 index 00000000..36d95ee7 --- /dev/null +++ b/TI-170.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +TODAY=$(date "+%Y%m%d") +YESTERDAY=$(date -d "yesterday" "+%Y%m%d") +CURRENT_HOUR=$(date +%k) + +function get_current_date_with_delta() +{ + local delta=${1} + + let "hour = CURRENT_HOUR + delta" + + if [[ ${hour} -lt 0 ]] ; then + let "hour = hour + 24" + day=${YESTERDAY} + else + day=${TODAY} + fi + + if [[ ${hour} -lt 10 ]] ; then + hour="0${hour}" + fi + + echo "${day}T${hour}0000" +} + +export TIMEWARRIORDB=/home/lauft/Projects/timew/timewarriordb +rm -f ${TIMEWARRIORDB}/data/*.data +:> ${TIMEWARRIORDB}/timewarrior.cfg + +five_hours_before=$(get_current_date_with_delta "-5") +four_hours_before=$(get_current_date_with_delta "-4") +three_hours_before=$(get_current_date_with_delta "-3") +two_hours_before=$(get_current_date_with_delta "-2") +one_hour_before=$(get_current_date_with_delta "-1") +current_hour=$(get_current_date_with_delta "0") +one_hour_after=$(get_current_date_with_delta "1") +two_hours_after=$(get_current_date_with_delta "2") + +src/timew track ${two_hours_before} - ${two_hours_before} +src/timew track ${one_hour_before} - ${one_hour_before} +src/timew summary :year :ids + +src/timew move @2 ${three_hours_before} +#src/timew move @2 2018-08-01 + diff --git a/TI-189.sh b/TI-189.sh new file mode 100755 index 00000000..f8554d44 --- /dev/null +++ b/TI-189.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +TODAY=$(date "+%Y%m%d") +YESTERDAY=$(date -d "yesterday" "+%Y%m%d") +CURRENT_HOUR=$(date +%k) + +function get_current_date_with_delta() +{ + local delta=${1} + + let "hour = CURRENT_HOUR + delta" + + if [[ ${hour} -lt 0 ]] ; then + let "hour = hour + 24" + day=${YESTERDAY} + else + day=${TODAY} + fi + + if [[ ${hour} -lt 10 ]] ; then + hour="0${hour}" + fi + + echo "${day}T${hour}0000" +} + +export TIMEWARRIORDB=/tmp/timewarriordb +mkdir -p ${TIMEWARRIORDB} +rm -f ${TIMEWARRIORDB}/data/*.data +:> ${TIMEWARRIORDB}/timewarrior.cfg + +five_hours_before=$(get_current_date_with_delta "-5") +four_hours_before=$(get_current_date_with_delta "-4") +three_hours_before=$(get_current_date_with_delta "-3") +two_hours_before=$(get_current_date_with_delta "-2") +one_hour_before=$(get_current_date_with_delta "-1") +current_hour=$(get_current_date_with_delta "0") +one_hour_after=$(get_current_date_with_delta "1") +two_hours_after=$(get_current_date_with_delta "2") + +src/timew get dom.active.tag.0 + +src/timew start FOO + +src/timew get dom.active.tag.0 +src/timew get dom.active.tag.1 + diff --git a/TI-57.sh b/TI-57.sh new file mode 100755 index 00000000..543e84b6 --- /dev/null +++ b/TI-57.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +TODAY=$(date "+%Y%m%d") +YESTERDAY=$(date -d "yesterday" "+%Y%m%d") +CURRENT_HOUR=$(date +%k) + +function get_current_date_with_delta() +{ + local delta=${1} + + let "hour = CURRENT_HOUR + delta" + + if [[ ${hour} -lt 0 ]] ; then + let "hour = hour + 24" + day=${YESTERDAY} + else + day=${TODAY} + fi + + if [[ ${hour} -lt 10 ]] ; then + hour="0${hour}" + fi + + echo "${day}T${hour}0000" +} + +export TIMEWARRIORDB=/home/lauft/Projects/timew/timewarriordb +rm -f ${TIMEWARRIORDB}/data/*.data +:> ${TIMEWARRIORDB}/timewarrior.cfg + +five_hours_before=$(get_current_date_with_delta "-5") +four_hours_before=$(get_current_date_with_delta "-4") +three_hours_before=$(get_current_date_with_delta "-3") +two_hours_before=$(get_current_date_with_delta "-2") +one_hour_before=$(get_current_date_with_delta "-1") +current_hour=$(get_current_date_with_delta "0") +one_hour_after=$(get_current_date_with_delta "1") +two_hours_after=$(get_current_date_with_delta "2") + +src/timew track ${one_hour_before} - ${one_hour_after} AHEAD +src/timew track ${one_hour_after} - ${two_hours_after} FUTURE + diff --git a/TI-62.sh b/TI-62.sh new file mode 100755 index 00000000..106acd84 --- /dev/null +++ b/TI-62.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +TODAY=$(date "+%Y%m%d") +YESTERDAY=$(date -d "yesterday" "+%Y%m%d") +CURRENT_HOUR=$(date +%k) + +function get_current_date_with_delta() +{ + local delta=${1} + + let "hour = CURRENT_HOUR + delta" + + if [[ ${hour} -lt 0 ]] ; then + let "hour = hour + 24" + day=${YESTERDAY} + else + day=${TODAY} + fi + + if [[ ${hour} -lt 10 ]] ; then + hour="0${hour}" + fi + + echo "${day}T${hour}0000" +} + +export TIMEWARRIORDB=/home/lauft/Projects/timew/timewarriordb +rm -f ${TIMEWARRIORDB}/data/*.data +:> ${TIMEWARRIORDB}/timewarrior.cfg + +five_hours_before=$(get_current_date_with_delta "-5") +four_hours_before=$(get_current_date_with_delta "-4") +three_hours_before=$(get_current_date_with_delta "-3") +two_hours_before=$(get_current_date_with_delta "-2") +one_hour_before=$(get_current_date_with_delta "-1") +current_hour=$(get_current_date_with_delta "0") +one_hour_after=$(get_current_date_with_delta "1") +two_hours_after=$(get_current_date_with_delta "2") + +src/timew track ${one_hour_before} - ${one_hour_after} + diff --git a/TI-XX.sh b/TI-XX.sh new file mode 100755 index 00000000..4e16b211 --- /dev/null +++ b/TI-XX.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +TODAY=$(date "+%Y%m%d") +YESTERDAY=$(date -d "yesterday" "+%Y%m%d") +CURRENT_HOUR=$(date +%k) + +function get_current_date_with_delta() +{ + local delta=${1} + + let "hour = CURRENT_HOUR + delta" + + if [[ ${hour} -lt 0 ]] ; then + let "hour = hour + 24" + day=${YESTERDAY} + else + day=${TODAY} + fi + + if [[ ${hour} -lt 10 ]] ; then + hour="0${hour}" + fi + + echo "${day}T${hour}0000" +} + +export TIMEWARRIORDB=/tmp/timewarriordb +mkdir -p ${TIMEWARRIORDB} +rm -f ${TIMEWARRIORDB}/data/*.data +:> ${TIMEWARRIORDB}/timewarrior.cfg + +five_hours_before=$(get_current_date_with_delta "-5") +four_hours_before=$(get_current_date_with_delta "-4") +three_hours_before=$(get_current_date_with_delta "-3") +two_hours_before=$(get_current_date_with_delta "-2") +one_hour_before=$(get_current_date_with_delta "-1") +current_hour=$(get_current_date_with_delta "0") +one_hour_after=$(get_current_date_with_delta "1") +two_hours_after=$(get_current_date_with_delta "2") + diff --git a/doc/holidays/.editorconfig b/doc/holidays/.editorconfig new file mode 100644 index 00000000..2fde1fa8 --- /dev/null +++ b/doc/holidays/.editorconfig @@ -0,0 +1,10 @@ +# top-most EditorConfig file +root = false + +# Unix-style newlines with a newline ending every file +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 4 diff --git a/ext/summary.py b/ext/summary.py new file mode 100755 index 00000000..ab64322c --- /dev/null +++ b/ext/summary.py @@ -0,0 +1,6 @@ +#!/usr/bin/env python + +import sys + +for line in sys.stdin: + print line.strip() diff --git a/pullupbranches b/pullupbranches new file mode 100755 index 00000000..614443ff --- /dev/null +++ b/pullupbranches @@ -0,0 +1,23 @@ +#!/bin/bash + +current_branch=$(git symbolic-ref HEAD 2>/dev/null) || { echo "you are on a unnamed branch" ; exit 1 ; } +current_branch=${current_branch##refs/heads/} + +git diff-index --quiet HEAD -- || { echo "you have unstaged changes" ; exit 1 ; } + +branches=$(git for-each-ref --format='%(refname:short)' refs/heads/) + +echo "We are currently on ${current_branch}" + +for branch in ${branches}; do + if [[ ${branch%%/*} == 'feature' || ${branch} =~ TI-[0-9]+ ]] ; then + git checkout ${branch} + git rebase 1.1.0 || break + else + echo "skipping branch ${branch}" + continue + fi +done + +git checkout ${current_branch} + diff --git a/src/GranularDatetime.cpp b/src/GranularDatetime.cpp new file mode 100644 index 00000000..ceb54ffe --- /dev/null +++ b/src/GranularDatetime.cpp @@ -0,0 +1,36 @@ +#include "GranularDatetime.h" +#include +#include +#include + +GranularDatetime::GranularDatetime(Rules &rules, const std::string &input, const std::string &format) : Datetime() +{ + if (!input.empty()) { + std::string::size_type start = 0; + if (! parse (input, start, format)) + throw ::format ("'{1}' is not a valid date in the '{2}' format.", input, format); + } + + debug (::format ("Granular time, input {1}", this->toISOLocalExtended())); + + if (rules.has("record.granularity")) + this->correct_for_granularity(rules.getInteger("record.granularity", 0)); + + debug (::format ("Granular time, output {1}", this->toISOLocalExtended())); +} + +void GranularDatetime::correct_for_granularity(int granularity) +{ + debug (::format ("Granularity set to {1}", granularity)); + + int seconds = this->second(); + int minutes = this->minute(); + + debug (::format ("Seconds {1}, minutes {2}", seconds, minutes)); + + int minute_delta = granularity == 0 ? 0 : minutes % granularity; + + debug (::format ("Seconds {1}, minutes {2}", seconds, minutes-minute_delta)); + + this->_date -= minute_delta*60 + seconds; +} diff --git a/src/GranularDatetime.h b/src/GranularDatetime.h new file mode 100644 index 00000000..5f9ad761 --- /dev/null +++ b/src/GranularDatetime.h @@ -0,0 +1,16 @@ +#ifndef GRANULARDATETIME_H +#define GRANULARDATETIME_H + +#include +#include + +class GranularDatetime : public Datetime +{ +public: + GranularDatetime(Rules &rules, const std::string& input = "", const std::string& format = ""); + +private: + void correct_for_granularity(int granularity); +}; + +#endif // GRANULARDATETIME_H diff --git a/src/LegacyRulesWrapper.cpp b/src/LegacyRulesWrapper.cpp new file mode 100644 index 00000000..c341e567 --- /dev/null +++ b/src/LegacyRulesWrapper.cpp @@ -0,0 +1,35 @@ +#include + +LegacyRulesWrapper::LegacyRulesWrapper(Rules &rules) + : _rules(rules) +{} + +bool LegacyRulesWrapper::has (const std::string& key) const +{ + return _rules.has(key); +} + +std::string LegacyRulesWrapper::get (const std::string& key) const +{ + return _rules.get(key); +} + +int LegacyRulesWrapper::getInteger (const std::string& key, int defaultValue) const +{ + return _rules.getInteger(key, defaultValue); +} + +double LegacyRulesWrapper::getReal (const std::string& key) const +{ + return _rules.getReal(key); +} + +bool LegacyRulesWrapper::getBoolean (const std::string& key) const +{ + return _rules.getBoolean(key); +} + +std::vector LegacyRulesWrapper::all (const std::string& stem = "") const +{ + return _rules.all(stem); +} diff --git a/src/LegacyRulesWrapper.h b/src/LegacyRulesWrapper.h new file mode 100644 index 00000000..fac20a4c --- /dev/null +++ b/src/LegacyRulesWrapper.h @@ -0,0 +1,24 @@ +#ifndef INCLUDED_LEGACYRULESWRAPPER +#define INCLUDED_LEGACYRULESWRAPPER + +#include +#include + +class LegacyRulesWrapper : public RulesProvider +{ +public: + explicit LegacyRulesWrapper(Rules &rules); + + bool has (const std::string&) const override; + std::string get (const std::string&) const override; + int getInteger (const std::string&, int defaultValue) const override; + double getReal (const std::string&) const override; + bool getBoolean (const std::string&) const override; + + std::vector all (const std::string& stem) const; + +private: + Rules& _rules; +}; + +#endif diff --git a/src/RulesProvider.h b/src/RulesProvider.h new file mode 100644 index 00000000..614622b8 --- /dev/null +++ b/src/RulesProvider.h @@ -0,0 +1,16 @@ +#ifndef INCLUDED_RULESPROVIDER +#define INCLUDED_RULESPROVIDER + +class RulesProvider +{ +public: + virtual bool has (const std::string&) const = 0; + virtual std::string get (const std::string&) const = 0; + virtual int getInteger (const std::string&, int defaultValue) const = 0; + virtual double getReal (const std::string&) const = 0; + virtual bool getBoolean (const std::string&) const = 0; + + virtual std::vector all (const std::string& stem = "") const = 0; +}; + +#endif diff --git a/src/dom.cpp b/src/dom.cpp index 81496d3e..b413726e 100644 --- a/src/dom.cpp +++ b/src/dom.cpp @@ -1,6 +1,6 @@ //////////////////////////////////////////////////////////////////////////////// // -// Copyright 2015 - 2016, Paul Beckingham, Federico Hernandez. +// Copyright 2016, 2018, Paul Beckingham, Federico Hernandez. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -90,7 +90,7 @@ bool domGet ( if (pig.skipLiteral (".tag.") && pig.getDigits (n)) { - if (n <= static_cast (latest.tags ().size ())) + if (1 <= n && n <= static_cast (latest.tags ().size ())) { std::vector tags; for (auto& tag : latest.tags ()) diff --git a/test/.editorconfig b/test/.editorconfig new file mode 100644 index 00000000..c47afadd --- /dev/null +++ b/test/.editorconfig @@ -0,0 +1,13 @@ +# top-most EditorConfig file +root = false + +# Unix-style newlines with a newline ending every file +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 2 + +[{*.py,*.t}] +indent_size = 4 diff --git a/test/IntervalSynthesizer.t b/test/IntervalSynthesizer.t new file mode 100755 index 00000000..5da34361 Binary files /dev/null and b/test/IntervalSynthesizer.t differ diff --git a/test/RulesProviderMock.h b/test/RulesProviderMock.h new file mode 100644 index 00000000..46d74c2c --- /dev/null +++ b/test/RulesProviderMock.h @@ -0,0 +1,16 @@ +#ifndef INCLUDED_RULESMOCK +#define INCLUDED_RULESMOCK + +#include +#include + +class RulesProviderMock : public RulesProvider +{ + MOCK_CONST_METHOD1(has, bool (const std::string&)); + MOCK_CONST_METHOD1(get, std::string (const std::string&)); + MOCK_CONST_METHOD2(getInteger, int (const std::string&, int defaultValue)); + MOCK_CONST_METHOD1(getReal, double (const std::string&)); + MOCK_CONST_METHOD1(getBoolean, bool (const std::string&)); +}; + +#endif diff --git a/test/TagInfoDatabase.t b/test/TagInfoDatabase.t new file mode 100755 index 00000000..2c2cc833 Binary files /dev/null and b/test/TagInfoDatabase.t differ diff --git a/test/get_all_exclusions.t b/test/get_all_exclusions.t new file mode 100755 index 00000000..d36ff462 Binary files /dev/null and b/test/get_all_exclusions.t differ diff --git a/test/granulardatetime.t.cpp b/test/granulardatetime.t.cpp new file mode 100644 index 00000000..05b07cb8 --- /dev/null +++ b/test/granulardatetime.t.cpp @@ -0,0 +1,21 @@ +//////////////////////////////////////////////////////////////////////////////// + +#include +#include +#include + +//////////////////////////////////////////////////////////////////////////////// + +void test_granular_datetime (UnitTest& t) +{ + +} + +//////////////////////////////////////////////////////////////////////////////// +int main (int, char**) +{ + int planned = 1; + UnitTest t(planned); + + test_granular_datetime(t); +} diff --git a/test/task_modify-1.json b/test/task_modify-1.json new file mode 100644 index 00000000..74a6d5b2 --- /dev/null +++ b/test/task_modify-1.json @@ -0,0 +1,14 @@ +{ + "description": "Hey Foo", + "entry": "20180316T231055Z", + "modified": "20180316T232042Z", + "status": "pending", + "uuid": "d07b40c4-5df7-409f-bf98-930e550333b3" +} +{ + "description": "Hello World", + "entry": "20180316T231055Z", + "modified": "20180316T232042Z", + "status": "pending", + "uuid": "d07b40c4-5df7-409f-bf98-930e550333b3" +} diff --git a/test/task_modify-2.json b/test/task_modify-2.json new file mode 100644 index 00000000..c8a60295 --- /dev/null +++ b/test/task_modify-2.json @@ -0,0 +1,15 @@ +{ + "description": "FooBar", + "entry": "20180316T231125Z", + "modified": "20180316T231808Z", + "status": "pending", + "uuid": "e11d7d19-20a7-47bb-999e-6554a70ea094" +} +{ + "description": "FooBar", + "due": "20180331T220000Z", + "entry": "20180316T231125Z", + "modified": "20180316T231808Z", + "status": "pending", + "uuid": "e11d7d19-20a7-47bb-999e-6554a70ea094" +} diff --git a/test/task_modify-3.json b/test/task_modify-3.json new file mode 100644 index 00000000..2b93b3dc --- /dev/null +++ b/test/task_modify-3.json @@ -0,0 +1,15 @@ +{ + "description": "FooBar", + "entry": "20180316T231125Z", + "modified": "20180316T231808Z", + "status": "pending", + "uuid": "e11d7d19-20a7-47bb-999e-6554a70ea094" +} +{ + "description": "FooBar", + "due": "20180331T220000Z", + "entry": "20180316T231125Z", + "modified": "20180316T231808Z", + "status": "pending", + "uuid": "e11d7d19-20a7-47bb-999e-6554a70ea094" +} diff --git a/test/test_csv.t b/test/test_csv.t new file mode 100755 index 00000000..ad15666d --- /dev/null +++ b/test/test_csv.t @@ -0,0 +1,85 @@ +#!/usr/bin/env python2.7 +# -*- coding: utf-8 -*- +############################################################################### +# +# Copyright 2006 - 2017, Thomas Lauf, Paul Beckingham, Federico Hernandez. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# http://www.opensource.org/licenses/mit-license.php +# +############################################################################### + +import os +import subprocess +import sys +import unittest + +# Ensure python finds the local simpletap module +sys.path.append(os.path.dirname(os.path.abspath(__file__))) + +from basetest import TestCase + + +class TestCsv(TestCase): + def setUp(self): + current_dir = os.path.dirname(os.path.abspath(__file__)) + self.process = subprocess.Popen([os.path.join(current_dir, '../ext/csv.py')], + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + + def test_csv_with_empty_database(self): + """csv extension should print nothing on empty database""" + out, err = self.process.communicate(input="color: off\ndebug: on\ntemp.report.start: \ntemp.report.end: \n\n[]") + + self.assertEqual('', out) + self.assertEqual('', err) + + def test_csv_with_filled_database(self): + """csv extension should print intervals for filled database""" + out, err = self.process.communicate( + input="color: off\ndebug: on\ntemp.report.start: 20160101T070000Z\ntemp.report.end: 20160101T080000Z\n\n[{\"start\":\"20160101T070000Z\",\"end\":\"20160101T080000Z\",\"tags\":[\"foo\"]}]") + + self.assertEqual('"20160101T070000Z","20160101T080000Z","foo"\n', out) + self.assertEqual('', err) + + def test_csv_with_interval_without_tags(self): + """csv extension should handle interval without tags""" + out, err = self.process.communicate( + input="color: off\ndebug: on\ntemp.report.start: 20160101T070000Z\ntemp.report.end: 20160101T080000Z\n\n[{\"start\":\"20160101T070000Z\",\"end\":\"20160101T080000Z\"}]") + + self.assertEqual('"20160101T070000Z","20160101T080000Z"\n', out) + self.assertEqual('', err) + + def test_csv_with_interval_with_empty_tag_list(self): + """csv extension should handle interval with empty tag list""" + out, err = self.process.communicate( + input="color: off\ndebug: on\ntemp.report.start: 20160101T070000Z\ntemp.report.end: 20160101T080000Z\n\n[{\"start\":\"20160101T070000Z\",\"end\":\"20160101T080000Z\"}]") + + self.assertEqual('"20160101T070000Z","20160101T080000Z"\n', out) + self.assertEqual('', err) + + +if __name__ == "__main__": + from simpletap import TAPTestRunner + + unittest.main(testRunner=TAPTestRunner()) + +# vim: ai sts=4 et sw=4 ft=python diff --git a/test/test_debug.t b/test/test_debug.t new file mode 100755 index 00000000..1cf1f13a --- /dev/null +++ b/test/test_debug.t @@ -0,0 +1,91 @@ +#!/usr/bin/env python2.7 +# -*- coding: utf-8 -*- +############################################################################### +# +# Copyright 2006 - 2017, Thomas Lauf, Paul Beckingham, Federico Hernandez. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# http://www.opensource.org/licenses/mit-license.php +# +############################################################################### + +import os +import subprocess +import sys +import unittest + +# Ensure python finds the local simpletap module +sys.path.append(os.path.dirname(os.path.abspath(__file__))) + +from basetest import TestCase + + +class TestDebug(TestCase): + def setUp(self): + current_dir = os.path.dirname(os.path.abspath(__file__)) + self.process = subprocess.Popen([os.path.join(current_dir, '../ext/debug.py')], + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + + def test_debug_with_empty_database(self): + """debug extension should print nothing on empty database""" + out, err = self.process.communicate(input="color: off\ndebug: on\ntemp.report.start: \ntemp.report.end: \n\n[]") + + self.assertEqual('color: off\ndebug: on\ntemp.report.start:\ntemp.report.end:\n\n[]\n', out) + self.assertEqual('', err) + + def test_debug_with_filled_database(self): + """debug extension should print intervals for filled database""" + out, err = self.process.communicate( + input="color: off\ndebug: on\ntemp.report.start: 20160101T070000Z\ntemp.report.end: 20160101T080000Z\n\n[{\"start\":\"20160101T070000Z\",\"end\":\"20160101T080000Z\",\"tags\":[\"foo\"]}]") + + self.assertEqual( + 'color: off\ndebug: on\ntemp.report.start: 20160101T070000Z\ntemp.report.end: 20160101T080000Z\n\n[{\"start\":\"20160101T070000Z\",\"end\":\"20160101T080000Z\",\"tags\":[\"foo\"]}]\n', + out) + self.assertEqual('', err) + + def test_debug_with_interval_without_tags(self): + """debug extension should handle intervals without tags""" + out, err = self.process.communicate( + input="color: off\ndebug: on\ntemp.report.start: 20160101T070000Z\ntemp.report.end: 20160101T080000Z\n\n[{\"start\":\"20160101T070000Z\",\"end\":\"20160101T080000Z\"}]") + + self.assertEqual( + 'color: off\ndebug: on\ntemp.report.start: 20160101T070000Z\ntemp.report.end: 20160101T080000Z\n\n[{\"start\":\"20160101T070000Z\",\"end\":\"20160101T080000Z\"}]\n', + out) + self.assertEqual('', err) + + def test_totals_with_interval_with_empty_tag_list(self): + """totals extension should handle interval with empty tag list""" + out, err = self.process.communicate( + input="color: off\ndebug: on\ntemp.report.start: 20160101T070000Z\ntemp.report.end: 20160101T080000Z\n\n[{\"start\":\"20160101T070000Z\",\"end\":\"20160101T080000Z\",\"tags\":[]}]") + + self.assertEqual( + 'color: off\ndebug: on\ntemp.report.start: 20160101T070000Z\ntemp.report.end: 20160101T080000Z\n\n[{\"start\":\"20160101T070000Z\",\"end\":\"20160101T080000Z\",\"tags\":[]}]\n', + out) + self.assertEqual('', err) + + +if __name__ == "__main__": + from simpletap import TAPTestRunner + + unittest.main(testRunner=TAPTestRunner()) + +# vim: ai sts=4 et sw=4 ft=python diff --git a/test/timemachine b/test/timemachine new file mode 100755 index 00000000..290bf271 --- /dev/null +++ b/test/timemachine @@ -0,0 +1,43 @@ +#!/bin/bash + +# parse options/arguments +until [ -z "${1}" ] ; do + case "${1}" in + --minute) + shift + minutes="${minutes} ${1}" + ;; + --hour) + shift + hours="${hours} ${1}" + ;; + --day) + shift + days="${days} ${1}" + ;; + -*) + echo "Unknown option '${1}'" + exit 1 + ;; + *) + tests="${tests} ${1}" + ;; + esac + shift +done + +for day in ${days-$(date --rfc-3339=date)} ; do + for minute in ${minutes-$(echo "0$(rand -M 60)" | sed "s|.\+\(..\)\$|\1|g")} ; do + for hour in ${hours-$(seq -w 0 23)} ; do + date="${day}T${hour}:${minute}" + for single_test in ${tests} ; do + echo "Running test ${single_test} at ${date}" + faketime ${date} ${single_test} + if [ $? -ne 0 ] ; then + echo "Test ${single_test} broke at ${date}!" + break 2 + fi + done + done + done +done diff --git a/timew.cbp b/timew.cbp new file mode 100644 index 00000000..c6102aab --- /dev/null +++ b/timew.cbp @@ -0,0 +1,1221 @@ + + + + + +