Taskw end: Ensure a task don't go on several days
This commit is contained in:
parent
cb7c5eafc0
commit
26e1884922
11
zshrc
11
zshrc
|
@ -749,9 +749,12 @@ function tiend() {
|
||||||
# Get time tracking's description from all time tracking of this year
|
# Get time tracking's description from all time tracking of this year
|
||||||
local tiend_time_desc=$(timew summary :year :ids | sed -n "s/.*@\(${tiend_time_id} .*\)/\1/p" | sed 's/ */ − /g')
|
local tiend_time_desc=$(timew summary :year :ids | sed -n "s/.*@\(${tiend_time_id} .*\)/\1/p" | sed 's/ */ − /g')
|
||||||
|
|
||||||
|
# Get time tracking's start day from all time tracking
|
||||||
|
local tiend_time_start_day=$(timew export | sed -nE "s/^\{\"id\":${tiend_time_id},\"start\":\"([0-9]{4})([0-9]{2})([0-9]{2})T.*end.*/\1-\2-\3/p")
|
||||||
|
|
||||||
# Check or ask for new end time {{{
|
# Check or ask for new end time {{{
|
||||||
if [ -z "${tiend_time_new_end}" ]; then
|
if [ -z "${tiend_time_new_end}" ]; then
|
||||||
printf '%b' "Enter the ${MAGENTAB}new end time${RESET} (or new date 'YYYY-MM-DD${REDB}T${RESET}HH:MM:SS') for this time tracking : "
|
printf '%b' "Enter the ${MAGENTAB}new end time${RESET} (or new date 'YYYY-MM-DD${REDB}T${RESET}HH:MM:SS'; default day is ${tiend_time_start_day}) for this time tracking : "
|
||||||
read -r tiend_time_new_end
|
read -r tiend_time_new_end
|
||||||
fi
|
fi
|
||||||
# }}}
|
# }}}
|
||||||
|
@ -761,8 +764,14 @@ function tiend() {
|
||||||
|
|
||||||
# Check confirmation
|
# Check confirmation
|
||||||
if printf -- '%s' "${tiend_confirmation:=y}" | grep --quiet --word-regexp -- "y"; then
|
if printf -- '%s' "${tiend_confirmation:=y}" | grep --quiet --word-regexp -- "y"; then
|
||||||
|
## If the new end time entered by user contains a "T" (user enter a dateTtime)
|
||||||
|
if printf -- '%s' "${tiend_time_new_end}" | grep --quiet -- "T"; then
|
||||||
timew modify end @"${tiend_time_id}" "${tiend_time_new_end}" || return 0
|
timew modify end @"${tiend_time_id}" "${tiend_time_new_end}" || return 0
|
||||||
printf '%b' "End time of ${tiend_time_desc} is now ${tiend_time_new_end}."
|
printf '%b' "End time of ${tiend_time_desc} is now ${tiend_time_new_end}."
|
||||||
|
else
|
||||||
|
timew modify end @"${tiend_time_id}" "${tiend_time_start_day}T${tiend_time_new_end}" || return 0
|
||||||
|
printf '%b' "End time of ${tiend_time_desc} is now ${tiend_time_start_day}T${tiend_time_new_end}."
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Unset defined variables
|
# Unset defined variables
|
||||||
|
|
Loading…
Reference in New Issue