chore: revamp to fit new standard
This commit is contained in:
parent
bc2ef9b781
commit
6ff5828ff2
26
README
26
README
|
@ -1,3 +1,28 @@
|
|||
|
||||
generate-year.sh
|
||||
----------------
|
||||
|
||||
usage:
|
||||
./generate-year [year]
|
||||
|
||||
parameter [year] is optional, omit to use current year
|
||||
|
||||
user alias:
|
||||
|
||||
function te {
|
||||
local date=${1:-$(date -I)}
|
||||
local year=$(date -d $date +%Y)
|
||||
|
||||
local timedir="$HOME/plan/time"
|
||||
local archivedir="$timedir/archive"
|
||||
|
||||
if [[ $year < $(date +%Y) ]]; then
|
||||
vim -c "/$date" $archivedir/$year.timedot
|
||||
fi
|
||||
|
||||
vim -c "/$date" $timedir/$year.timedot
|
||||
}
|
||||
|
||||
generate-week.sh
|
||||
----------------
|
||||
|
||||
|
@ -10,3 +35,4 @@ user alias:
|
|||
function te () {
|
||||
$EDITOR ~/plan/time/current.timedot
|
||||
}
|
||||
|
||||
|
|
|
@ -37,27 +37,27 @@ fname="${time_dir}/${year}-${week}".timedot
|
|||
function weekdays () {
|
||||
local monday="$1"
|
||||
|
||||
days_in_week=(
|
||||
"$monday"
|
||||
days_in_week=(
|
||||
"$monday"
|
||||
$(date -d "$monday +1day" +%Y-%m-%d)
|
||||
$(date -d "$monday +2day" +%Y-%m-%d)
|
||||
$(date -d "$monday +3day" +%Y-%m-%d)
|
||||
$(date -d "$monday +4day" +%Y-%m-%d)
|
||||
$(date -d "$monday +5day" +%Y-%m-%d)
|
||||
$(date -d "$monday +6day" +%Y-%m-%d)
|
||||
)
|
||||
)
|
||||
|
||||
for day in "${days_in_week[@]}"; do
|
||||
local day_name="$(date -d $day +%A)"
|
||||
for day in "${days_in_week[@]}"; do
|
||||
local day_name="$(date -d $day +%A)"
|
||||
|
||||
echo "$day # $day_name"
|
||||
|
||||
echo "$day # $day_name"
|
||||
|
||||
if [[ ! -z $montofri_template && "$day_name" != "Saturday" && "$day_name" != "Sunday" ]]; then
|
||||
echo "$montofri_template"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
function write () {
|
||||
|
|
54
generate-year.sh
Executable file
54
generate-year.sh
Executable file
|
@ -0,0 +1,54 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
#
|
||||
## script arguments
|
||||
#
|
||||
|
||||
YEAR="${1:-$(date +%Y)}"
|
||||
|
||||
#
|
||||
## support functions
|
||||
#
|
||||
|
||||
function main () {
|
||||
local date_year_first="$(date -I -d "${1}-01-01")"
|
||||
local date_year_last="$(date -I -d "${date_year_first} + 1 year - 1 day")"
|
||||
|
||||
local start="$date_year_first"
|
||||
local stop="$date_year_last"
|
||||
|
||||
while ! [[ $start > $stop ]]; do
|
||||
local weekday=$(date -d "$start" +%u)
|
||||
local day_name="$(date -d "$start" +%A)"
|
||||
|
||||
local base_monday
|
||||
if [[ $weekday -eq 1 ]]; then
|
||||
base_monday=$start
|
||||
else
|
||||
overshoot=$(($weekday - 1))
|
||||
base_monday=$(date -I -d "$start -${overshoot}days")
|
||||
fi
|
||||
|
||||
week="$(date -d "$base_monday" +%V)"
|
||||
|
||||
echo "$start # ${day_name,,} w:$week"
|
||||
if [[ \
|
||||
"$day_name" != "Friday" && \
|
||||
"$day_name" != "Saturday" && \
|
||||
"$day_name" != "Sunday" \
|
||||
]]; then
|
||||
echo "amedia 8"
|
||||
fi
|
||||
|
||||
if [[ "$day_name" == "Friday" ]]; then
|
||||
echo "umara 8"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
start=$(date -I -d "$start + 1 day")
|
||||
done
|
||||
}
|
||||
|
||||
main $YEAR
|
Loading…
Reference in a new issue