improvement: consistent use of delimiter
This commit is contained in:
parent
428b9de85c
commit
3b8c412885
@ -1,5 +1,13 @@
|
|||||||
## src/awk/approx.awk
|
## src/awk/approx.awk
|
||||||
|
##
|
||||||
## Generate single-line approximate information for every iCalendar argument.
|
## Generate single-line approximate information for every iCalendar argument.
|
||||||
|
## The fields in each line are separated by "\t"
|
||||||
|
## The fields are the following:
|
||||||
|
## 1. "~" (constant, indicating that the lines contains approximate information)
|
||||||
|
## 2. start (this can be used in date (1))
|
||||||
|
## 3. end (this can be used in date (1)
|
||||||
|
## 4. string to display
|
||||||
|
## 5. filename (collection/name)
|
||||||
##
|
##
|
||||||
## @assign collection_labels: See configuration of the current program.
|
## @assign collection_labels: See configuration of the current program.
|
||||||
|
|
||||||
@ -26,7 +34,7 @@ function fn(path, n, a) {
|
|||||||
function title(start, summary) {
|
function title(start, summary) {
|
||||||
summary = getcontent(summary)
|
summary = getcontent(summary)
|
||||||
gsub("\n", " ", summary) # This will be put on a single line
|
gsub("\n", " ", summary) # This will be put on a single line
|
||||||
gsub("\\|", ":", summary) # we use "|" as delimiter
|
gsub("\\t", " ", summary) # we use "\t" as delimiter
|
||||||
depth = split(FILENAME, path, "/")
|
depth = split(FILENAME, path, "/")
|
||||||
collection = depth > 1 ? path[depth-1] : ""
|
collection = depth > 1 ? path[depth-1] : ""
|
||||||
collection = collection in collection2label ? collection2label[collection] : collection
|
collection = collection in collection2label ? collection2label[collection] : collection
|
||||||
@ -36,7 +44,7 @@ function title(start, summary) {
|
|||||||
# AWK program
|
# AWK program
|
||||||
BEGIN {
|
BEGIN {
|
||||||
FS="[:;=]"
|
FS="[:;=]"
|
||||||
OFS="|"
|
OFS="\t"
|
||||||
split(collection_labels, mapping, ";")
|
split(collection_labels, mapping, ";")
|
||||||
for (map in mapping)
|
for (map in mapping)
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,22 @@
|
|||||||
## src/awk/dayview.awk
|
## src/awk/dayview.awk
|
||||||
## Generate the view of a day from lines of the form
|
## Take as input (tab-delimited):
|
||||||
## ```
|
## 1. s (start time, as HH:MM)
|
||||||
## <start_date>|<end_date>|<start_time>|<end_time>|<file_path>|<collection>|<description>
|
## 2. e (end time, as HH:MM)
|
||||||
## ```.
|
## 3. starttime
|
||||||
|
## 4. endtime
|
||||||
|
## 5. fpath
|
||||||
|
## 6. collection
|
||||||
|
## 7. description
|
||||||
|
## 8. status
|
||||||
|
##
|
||||||
|
## filter out irrelevant lines, and generate the view of a day
|
||||||
|
## (tab-delimited), including empty hours:
|
||||||
|
## 1. start date
|
||||||
|
## 2. start time
|
||||||
|
## 3. end time
|
||||||
|
## 4. file path
|
||||||
|
## 5. collection
|
||||||
|
## 6. description
|
||||||
##
|
##
|
||||||
## @assign today: Date of `today` in the format %D (%m/%d/%y)
|
## @assign today: Date of `today` in the format %D (%m/%d/%y)
|
||||||
## @assign daystart: Hour of start of the day
|
## @assign daystart: Hour of start of the day
|
||||||
@ -91,14 +105,14 @@ function hrlines(start, stop, h, starth, stoph, tmp, i) {
|
|||||||
|
|
||||||
# AWK program
|
# AWK program
|
||||||
BEGIN {
|
BEGIN {
|
||||||
FS = "|"
|
FS = "\t"
|
||||||
|
OFS = "\t"
|
||||||
LIGHT_CYAN = "\033[1;36m"
|
LIGHT_CYAN = "\033[1;36m"
|
||||||
CYAN = "\033[1;36m"
|
CYAN = "\033[1;36m"
|
||||||
ITALIC = "\033[3m"
|
ITALIC = "\033[3m"
|
||||||
FAINT = "\033[2m"
|
FAINT = "\033[2m"
|
||||||
STRIKE = "\033[9m"
|
STRIKE = "\033[9m"
|
||||||
OFF = "\033[m"
|
OFF = "\033[m"
|
||||||
OFS = "|"
|
|
||||||
}
|
}
|
||||||
$1 == "00:00" && $2 == "00:00" { print today, $1, $3, $4, $5, allday($6, $7, $8); next }
|
$1 == "00:00" && $2 == "00:00" { print today, $1, $3, $4, $5, allday($6, $7, $8); next }
|
||||||
$1 == "00:00" { print today, $1, $3, $4, $5, endstoday($2, $6, $7, $8); next }
|
$1 == "00:00" { print today, $1, $3, $4, $5, endstoday($2, $6, $7, $8); next }
|
||||||
|
@ -4,14 +4,16 @@
|
|||||||
## to the weeks at which the events take place.
|
## to the weeks at which the events take place.
|
||||||
|
|
||||||
# AWK program
|
# AWK program
|
||||||
BEGIN { FS="|" }
|
BEGIN { FS="\t"; OFS="\t" }
|
||||||
NR == FNR {
|
NR == FNR {
|
||||||
i = i + 1
|
i = i + 1
|
||||||
from_year[i] = $1
|
split($0, parts, ":")
|
||||||
from_week[i] = $2
|
from_year[i] = parts[1]
|
||||||
|
from_week[i] = parts[2]
|
||||||
getline
|
getline
|
||||||
to_year[i] = $1
|
split($0, parts, ":")
|
||||||
to_week[i] = $2
|
to_year[i] = parts[1]
|
||||||
|
to_week[i] = parts[2]
|
||||||
next
|
next
|
||||||
} # Load start and end week numbers from first file
|
} # Load start and end week numbers from first file
|
||||||
|
|
||||||
@ -21,8 +23,8 @@ NR == FNR {
|
|||||||
year_end = to_year[FNR]
|
year_end = to_year[FNR]
|
||||||
week_end = to_week[FNR]
|
week_end = to_week[FNR]
|
||||||
while(year_i <= year_end && (year_i < year_end || week_i <= week_end)) {
|
while(year_i <= year_end && (year_i < year_end || week_i <= week_end)) {
|
||||||
label = year_i"|"week_i
|
label = year_i ":" week_i ":"
|
||||||
week[label] = week[label] " " $5
|
week[label] = week[label] ? week[label] " " $5 : $5
|
||||||
week_i++
|
week_i++
|
||||||
if (week_i > 53) {
|
if (week_i > 53) {
|
||||||
week_i = 1
|
week_i = 1
|
||||||
@ -30,4 +32,4 @@ NR == FNR {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
END { for (label in week) print label week[label] }
|
END { for (label in week) print label, week[label] }
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
## ```
|
## ```
|
||||||
## <start> <end> <fpath> <collection> <status> <summary>
|
## <start> <end> <fpath> <collection> <status> <summary>
|
||||||
## ```.
|
## ```.
|
||||||
|
## The output is space delimited.
|
||||||
|
## Summary may contain spaces, but it's the last in the list.
|
||||||
##
|
##
|
||||||
## @assign collection_labels: See configuration of the current program.
|
## @assign collection_labels: See configuration of the current program.
|
||||||
|
|
||||||
@ -18,6 +20,7 @@
|
|||||||
function print_data(start, dur, end, summary, cmd, collection, depth, path) {
|
function print_data(start, dur, end, summary, cmd, collection, depth, path) {
|
||||||
summary = getcontent(summary)
|
summary = getcontent(summary)
|
||||||
gsub("\n", " ", summary) # This will be put on a single line
|
gsub("\n", " ", summary) # This will be put on a single line
|
||||||
|
gsub("\t", " ", summary) # Generally, we use tab as delimiter.
|
||||||
depth = split(FILENAME, path, "/")
|
depth = split(FILENAME, path, "/")
|
||||||
fpath = path[depth-1] "/" path[depth]
|
fpath = path[depth-1] "/" path[depth]
|
||||||
collection = depth > 1 ? path[depth-1] : ""
|
collection = depth > 1 ? path[depth-1] : ""
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
## src/awk/weekview.awk
|
## src/awk/weekview.awk
|
||||||
## Print view of all appointments of the current week.
|
## Print view of all appointments of the current week.
|
||||||
|
## Generates view from
|
||||||
|
## printf "%s\t%s\t%s\t%s\n" "$i" "$s" "$e" "$description"
|
||||||
##
|
##
|
||||||
## @assign startofweek: Date of first day in the week
|
## @assign startofweek: Date of first day in the week
|
||||||
|
|
||||||
@ -7,27 +9,29 @@
|
|||||||
|
|
||||||
# Compose line that will display a day in the week.
|
# Compose line that will display a day in the week.
|
||||||
#
|
#
|
||||||
|
# @input desc: String with a description of the event
|
||||||
# @return: Single-line string
|
# @return: Single-line string
|
||||||
function c() {
|
function c(desc) {
|
||||||
return CYAN substr($0, index($0, ">") + 1) OFF " " RED "/" OFF
|
return CYAN desc OFF " " RED "/" OFF
|
||||||
}
|
}
|
||||||
|
|
||||||
# AWK program
|
# AWK program
|
||||||
|
|
||||||
BEGIN {
|
BEGIN {
|
||||||
|
FS = "\t"
|
||||||
|
OFS = "\t"
|
||||||
GREEN = "\033[1;32m"
|
GREEN = "\033[1;32m"
|
||||||
RED = "\033[1;31m"
|
RED = "\033[1;31m"
|
||||||
CYAN = "\033[1;36m"
|
CYAN = "\033[1;36m"
|
||||||
OFF = "\033[m"
|
OFF = "\033[m"
|
||||||
OFS = "|"
|
|
||||||
}
|
}
|
||||||
/^[0-7] 00:00 -- 00:00/ { dayline = dayline " " c(); next }
|
$2 == "00:00" && $3 == "00:00" { dayline = dayline " " c($4); next }
|
||||||
/^[0-7] 00:00 -- / { dayline = dayline " → " $4 " " c(); next }
|
$2 == "00:00" { dayline = dayline " → " $3 " " c($4); next }
|
||||||
/^[0-7] [0-9]{2}:[0-9]{2} -- 00:00/ { dayline = dayline " " $2 " → " c(); next }
|
$3 == "00:00" { dayline = dayline " " $2 " → " c($4); next }
|
||||||
/^[0-7] [0-9]{2}:[0-9]{2} -- [0-9]{2}:[0-9]{2}/ { dayline = dayline " " $2 " – " $4 " " c(); next }
|
NF == 4 { dayline = dayline " " $2 " – " $3 " " c($4); next }
|
||||||
/^[0-7]$/ && dayline { print "+", startofweek " +" $0-1 " days", "", dayline }
|
NF == 1 && dayline { print "+", startofweek " +" $1-1 " days", "", dayline }
|
||||||
/^[0-7]$/ {
|
NF == 1 {
|
||||||
cmd = "date -d '" startofweek " +" $0 " days' +\"%a %e %b %Y\""
|
cmd = "date -d '" startofweek " +" $1 " days' +\"%a %e %b %Y\""
|
||||||
cmd | getline dayline
|
cmd | getline dayline
|
||||||
close(cmd)
|
close(cmd)
|
||||||
dayline = GREEN dayline ": " OFF
|
dayline = GREEN dayline ": " OFF
|
||||||
|
32
src/main.sh
32
src/main.sh
@ -176,7 +176,7 @@ while true; do
|
|||||||
--list-border="top" \
|
--list-border="top" \
|
||||||
--list-label-pos=3 \
|
--list-label-pos=3 \
|
||||||
--cycle \
|
--cycle \
|
||||||
--delimiter='|' \
|
--delimiter='\t' \
|
||||||
--with-nth='{6}' \
|
--with-nth='{6}' \
|
||||||
--accept-nth='1,2,3,4,5' \
|
--accept-nth='1,2,3,4,5' \
|
||||||
--preview="$0 --preview-event {}" \
|
--preview="$0 --preview-event {}" \
|
||||||
@ -186,15 +186,15 @@ while true; do
|
|||||||
)+transform(
|
)+transform(
|
||||||
[ -n \"\${TZ:-}\" ] && echo \"change-list-label:\$WHITE\$ITALIC(\$TZ)\$OFF\"
|
[ -n \"\${TZ:-}\" ] && echo \"change-list-label:\$WHITE\$ITALIC(\$TZ)\$OFF\"
|
||||||
)+transform(
|
)+transform(
|
||||||
[ -n \"\$(echo {} | cut -d '|' -f 5)\" ] && echo show-preview
|
[ -n \"\$(echo {} | cut -f 5)\" ] && echo show-preview
|
||||||
)" \
|
)" \
|
||||||
--bind="start:hide-preview" \
|
--bind="start:hide-preview" \
|
||||||
--bind="j:down+hide-preview+transform([ -n \"\$(echo {} | cut -d '|' -f 5)\" ] && echo show-preview)" \
|
--bind="j:down+hide-preview+transform([ -n \"\$(echo {} | cut -f 5)\" ] && echo show-preview)" \
|
||||||
--bind="k:up+hide-preview+transform([ -n \"\$(echo {} | cut -d '|' -f 5)\" ] && echo show-preview)" \
|
--bind="k:up+hide-preview+transform([ -n \"\$(echo {} | cut -f 5)\" ] && echo show-preview)" \
|
||||||
--bind="ctrl-j:down+hide-preview+transform([ -n \"\$(echo {} | cut -d '|' -f 5)\" ] && echo show-preview)" \
|
--bind="ctrl-j:down+hide-preview+transform([ -n \"\$(echo {} | cut -f 5)\" ] && echo show-preview)" \
|
||||||
--bind="ctrl-k:up+hide-preview+transform([ -n \"\$(echo {} | cut -d '|' -f 5)\" ] && echo show-preview)" \
|
--bind="ctrl-k:up+hide-preview+transform([ -n \"\$(echo {} | cut -f 5)\" ] && echo show-preview)" \
|
||||||
--bind="down:down+hide-preview+transform([ -n \"\$(echo {} | cut -d '|' -f 5)\" ] && echo show-preview)" \
|
--bind="down:down+hide-preview+transform([ -n \"\$(echo {} | cut -f 5)\" ] && echo show-preview)" \
|
||||||
--bind="up:up+hide-preview+transform([ -n \"\$(echo {} | cut -d '|' -f 5)\" ] && echo show-preview)" \
|
--bind="up:up+hide-preview+transform([ -n \"\$(echo {} | cut -f 5)\" ] && echo show-preview)" \
|
||||||
--bind="l:hide-preview+reload:$0 --reload-day {1} '+1 day'" \
|
--bind="l:hide-preview+reload:$0 --reload-day {1} '+1 day'" \
|
||||||
--bind="h:hide-preview+reload:$0 --reload-day {1} '-1 day'" \
|
--bind="h:hide-preview+reload:$0 --reload-day {1} '-1 day'" \
|
||||||
--bind="right:hide-preview+reload:$0 --reload-day {1} '+1 day'" \
|
--bind="right:hide-preview+reload:$0 --reload-day {1} '+1 day'" \
|
||||||
@ -214,11 +214,11 @@ while true; do
|
|||||||
if [ "$line" = "$key" ]; then
|
if [ "$line" = "$key" ]; then
|
||||||
line=""
|
line=""
|
||||||
fi
|
fi
|
||||||
DISPLAY_DATE=$(echo "$line" | cut -d '|' -f 1)
|
DISPLAY_DATE=$(echo "$line" | cut -f 1)
|
||||||
hour=$(echo "$line" | cut -d '|' -f 2)
|
hour=$(echo "$line" | cut -f 2)
|
||||||
start=$(echo "$line" | cut -d '|' -f 3)
|
start=$(echo "$line" | cut -f 3)
|
||||||
end=$(echo "$line" | cut -d '|' -f 4)
|
end=$(echo "$line" | cut -f 4)
|
||||||
fpath=$(echo "$line" | cut -d '|' -f 5 | sed "s/ /|/g")
|
fpath=$(echo "$line" | cut -f 5)
|
||||||
if [ "$key" = "ctrl-n" ]; then
|
if [ "$key" = "ctrl-n" ]; then
|
||||||
if echo "$hour" | grep ":"; then
|
if echo "$hour" | grep ":"; then
|
||||||
hour="$DAY_START"
|
hour="$DAY_START"
|
||||||
@ -371,7 +371,7 @@ while true; do
|
|||||||
--no-sort \
|
--no-sort \
|
||||||
--no-hscroll \
|
--no-hscroll \
|
||||||
--ellipsis="" \
|
--ellipsis="" \
|
||||||
--delimiter="|" \
|
--delimiter="\t" \
|
||||||
--with-nth="{4}" \
|
--with-nth="{4}" \
|
||||||
--accept-nth=1,2 \
|
--accept-nth=1,2 \
|
||||||
--ansi \
|
--ansi \
|
||||||
@ -408,8 +408,8 @@ while true; do
|
|||||||
if [ "$line" = "$key" ]; then
|
if [ "$line" = "$key" ]; then
|
||||||
line=""
|
line=""
|
||||||
fi
|
fi
|
||||||
sign=$(echo "$line" | cut -d '|' -f 1)
|
sign=$(echo "$line" | cut -f 1)
|
||||||
DISPLAY_DATE=$(echo "$line" | cut -d '|' -f 2)
|
DISPLAY_DATE=$(echo "$line" | cut -f 2)
|
||||||
if [ "$key" = "ctrl-n" ]; then
|
if [ "$key" = "ctrl-n" ]; then
|
||||||
if [ "$sign" = "~" ]; then
|
if [ "$sign" = "~" ]; then
|
||||||
DISPLAY_DATE=""
|
DISPLAY_DATE=""
|
||||||
|
@ -6,10 +6,10 @@
|
|||||||
#
|
#
|
||||||
# @input $2: Line from day view containing an event
|
# @input $2: Line from day view containing an event
|
||||||
if [ "${1:-}" = "--preview-event" ]; then
|
if [ "${1:-}" = "--preview-event" ]; then
|
||||||
hour=$(echo "$2" | cut -d '|' -f 2)
|
hour=$(echo "$2" | cut -f 2)
|
||||||
start=$(echo "$2" | cut -d '|' -f 3)
|
start=$(echo "$2" | cut -f 3)
|
||||||
end=$(echo "$2" | cut -d '|' -f 4)
|
end=$(echo "$2" | cut -f 4)
|
||||||
fpath=$(echo "$2" | cut -d '|' -f 5 | sed "s/ /|/g")
|
fpath=$(echo "$2" | cut -f 5)
|
||||||
if [ -n "$hour" ] && [ -n "$fpath" ]; then
|
if [ -n "$hour" ] && [ -n "$fpath" ]; then
|
||||||
fpath="$ROOT/$fpath"
|
fpath="$ROOT/$fpath"
|
||||||
start=$(datetime_str "$start" "%a ")
|
start=$(datetime_str "$start" "%a ")
|
||||||
@ -39,9 +39,9 @@ fi
|
|||||||
#
|
#
|
||||||
# @input $2: Line from week view
|
# @input $2: Line from week view
|
||||||
if [ "${1:-}" = "--preview-week" ]; then
|
if [ "${1:-}" = "--preview-week" ]; then
|
||||||
sign=$(echo "$2" | cut -d '|' -f 1)
|
sign=$(echo "$2" | cut -f 1)
|
||||||
if [ "$sign" = "+" ]; then
|
if [ "$sign" = "+" ]; then
|
||||||
startdate=$(echo "$2" | cut -d '|' -f 2)
|
startdate=$(echo "$2" | cut -f 2)
|
||||||
set -- $(date -d "$startdate" +"%Y %m %d")
|
set -- $(date -d "$startdate" +"%Y %m %d")
|
||||||
year=$1
|
year=$1
|
||||||
month=$2
|
month=$2
|
||||||
|
@ -14,9 +14,9 @@ __load_approx_data() {
|
|||||||
|
|
||||||
# For every relevant week, print associated iCalendar files
|
# For every relevant week, print associated iCalendar files
|
||||||
__load_weeks() {
|
__load_weeks() {
|
||||||
dates=$(awk -F'|' '{ print $2; print $3 }' "$APPROX_DATA_FILE")
|
dates=$(awk -F'\t' '{ print $2; print $3 }' "$APPROX_DATA_FILE")
|
||||||
file_dates=$(mktemp)
|
file_dates=$(mktemp)
|
||||||
echo "$dates" | date --file="/dev/stdin" +"%G|%V" >"$file_dates"
|
echo "$dates" | date --file="/dev/stdin" +"%G:%V:" >"$file_dates"
|
||||||
awk "$AWK_MERGE" "$file_dates" "$APPROX_DATA_FILE"
|
awk "$AWK_MERGE" "$file_dates" "$APPROX_DATA_FILE"
|
||||||
rm "$file_dates"
|
rm "$file_dates"
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,17 @@
|
|||||||
# - __view_week
|
# - __view_week
|
||||||
# - __view_all
|
# - __view_all
|
||||||
|
|
||||||
# This function prints the view for the day specified in `$DISPLAY_DATE`.
|
# This function prints the view for the day specified in `$DISPLAY_DATE`, in
|
||||||
|
# the tab-delimited format with the fields:
|
||||||
|
# 1. start date
|
||||||
|
# 2. start time
|
||||||
|
# 3. end time
|
||||||
|
# 4. file path
|
||||||
|
# 5. collection
|
||||||
|
# 6. description
|
||||||
__view_day() {
|
__view_day() {
|
||||||
weeknr=$(date -d "$DISPLAY_DATE" +"%G.%V")
|
weeknr=$(date -d "$DISPLAY_DATE" +"%G:%V:")
|
||||||
files=$(grep "^$weeknr\ " "$WEEKLY_DATA_FILE" | cut -d " " -f 2-)
|
files=$(grep "^$weeknr" "$WEEKLY_DATA_FILE" | cut -f 2)
|
||||||
# Find relevant files in list of week files
|
# Find relevant files in list of week files
|
||||||
sef=$({
|
sef=$({
|
||||||
set -- $files
|
set -- $files
|
||||||
@ -17,6 +24,7 @@ __view_day() {
|
|||||||
"$AWK_PARSE" "$file"
|
"$AWK_PARSE" "$file"
|
||||||
done
|
done
|
||||||
})
|
})
|
||||||
|
# $sef holds (space-delimited): <start> <end> <fpath> <collection> <status> <summary>
|
||||||
today=$(date -d "$DISPLAY_DATE" +"%D")
|
today=$(date -d "$DISPLAY_DATE" +"%D")
|
||||||
if [ -n "$sef" ]; then
|
if [ -n "$sef" ]; then
|
||||||
sef=$(echo "$sef" | while IFS= read -r line; do
|
sef=$(echo "$sef" | while IFS= read -r line; do
|
||||||
@ -25,13 +33,13 @@ __view_day() {
|
|||||||
shift
|
shift
|
||||||
endtime="$1"
|
endtime="$1"
|
||||||
shift
|
shift
|
||||||
fpath="$(echo "$1" | sed 's/|/ /g')" # we will use | as delimiter (need to convert back!)
|
fpath="$1" # we will use | as delimiter (need to convert back!)
|
||||||
shift
|
shift
|
||||||
collection="$1"
|
collection="$1"
|
||||||
shift
|
shift
|
||||||
status="$1"
|
status="$1"
|
||||||
shift
|
shift
|
||||||
description="$(echo "$*" | sed 's/|/:/g')" # we will use | as delimiter
|
description="$*"
|
||||||
#
|
#
|
||||||
daystart=$(date -d "$today 00:00:00" +"%s")
|
daystart=$(date -d "$today 00:00:00" +"%s")
|
||||||
dayend=$(date -d "$today 23:59:59" +"%s")
|
dayend=$(date -d "$today 23:59:59" +"%s")
|
||||||
@ -50,7 +58,7 @@ __view_day() {
|
|||||||
else
|
else
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
echo "$s|$e|$starttime|$endtime|$fpath|$collection|$description|$status"
|
printf "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n" "$s" "$e" "$starttime" "$endtime" "$fpath" "$collection" "$description" "$status"
|
||||||
done)
|
done)
|
||||||
fi
|
fi
|
||||||
echo "$sef" | sort -n | awk -v today="$today" -v daystart="$DAY_START" -v dayend="$DAY_END" "$AWK_DAYVIEW"
|
echo "$sef" | sort -n | awk -v today="$today" -v daystart="$DAY_START" -v dayend="$DAY_END" "$AWK_DAYVIEW"
|
||||||
@ -58,8 +66,8 @@ __view_day() {
|
|||||||
|
|
||||||
# This function prints the view for the week that contains the day specified in `$DISPLAY_DATE`.
|
# This function prints the view for the week that contains the day specified in `$DISPLAY_DATE`.
|
||||||
__view_week() {
|
__view_week() {
|
||||||
weeknr=$(date -d "$DISPLAY_DATE" +"%G.%V")
|
weeknr=$(date -d "$DISPLAY_DATE" +"%G:%V:")
|
||||||
files=$(grep "^$weeknr\ " "$WEEKLY_DATA_FILE" | cut -d " " -f 2-)
|
files=$(grep "^$weeknr" "$WEEKLY_DATA_FILE" | cut -f 2)
|
||||||
dayofweek=$(date -d "$DISPLAY_DATE" +"%u")
|
dayofweek=$(date -d "$DISPLAY_DATE" +"%u")
|
||||||
delta=$((1 - dayofweek))
|
delta=$((1 - dayofweek))
|
||||||
startofweek=$(date -d "$DISPLAY_DATE -$delta days" +"%D")
|
startofweek=$(date -d "$DISPLAY_DATE -$delta days" +"%D")
|
||||||
@ -99,21 +107,19 @@ __view_week() {
|
|||||||
dayend=$(date -d "$startofweek +$i days 23:59:59" +"%s")
|
dayend=$(date -d "$startofweek +$i days 23:59:59" +"%s")
|
||||||
if [ "$starttime" -gt "$daystart" ] && [ "$starttime" -lt "$dayend" ]; then
|
if [ "$starttime" -gt "$daystart" ] && [ "$starttime" -lt "$dayend" ]; then
|
||||||
s=$(date -d "@$starttime" +"%H:%M")
|
s=$(date -d "@$starttime" +"%H:%M")
|
||||||
s="$s -"
|
|
||||||
elif [ "$starttime" -le "$daystart" ] && [ "$endtime" -gt "$daystart" ]; then
|
elif [ "$starttime" -le "$daystart" ] && [ "$endtime" -gt "$daystart" ]; then
|
||||||
s="00:00 -"
|
s="00:00"
|
||||||
else
|
else
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
if [ "$endtime" -gt "$daystart" ] && [ "$endtime" -lt "$dayend" ]; then
|
if [ "$endtime" -gt "$daystart" ] && [ "$endtime" -lt "$dayend" ]; then
|
||||||
e=$(date -d "@$endtime" +"%H:%M")
|
e=$(date -d "@$endtime" +"%H:%M")
|
||||||
e="- $e"
|
|
||||||
elif [ "$endtime" -ge "$dayend" ] && [ "$starttime" -lt "$dayend" ]; then
|
elif [ "$endtime" -ge "$dayend" ] && [ "$starttime" -lt "$dayend" ]; then
|
||||||
e="- 00:00"
|
e="00:00"
|
||||||
else
|
else
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
echo "$i $s$e >$description"
|
printf "%s\t%s\t%s\t%s\n" "$i" "$s" "$e" "$description"
|
||||||
done
|
done
|
||||||
done)
|
done)
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user