Create helper scripts to convert old calendar to new style.

This commit is contained in:
Christian Wolf 2025-01-16 17:32:55 +01:00
parent b68394ec68
commit 294c537f3f
2 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,23 @@
#!/bin/bash
echo "calendars:"
for r in vorne mitte hinten
do
echo " $r:"
echo " id: \"$r\""
echo " ignore: true"
echo " schedule:"
echo -n " "
(
echo '['
prefix_comma=''
for d in Mo Di Mi Do Fr
do
echo -n "$prefix_comma"
prefix_comma=', '
cat ../../data/calendar.yaml | yq -cj '.calendar.'"$r.$d"' | . as $dict | [keys[] | . as $key | $dict[$key] | to_entries | [ .[], {key: "day", value: "'"$d"'"}, {key: "start", value: $key}, {key: "age", value: ""}, {key: "extern", value: false}, {key: "duration", value: (($dict[$key].slots) * 15)} ] | from_entries | del(.slots)]'
done
echo ']'
) | jq -cj '[ .[][] ]'
echo
done

View File

@ -0,0 +1,12 @@
.calendar.vorne.Mo | . as $dict |
keys[] | . as $key |
$dict[$key] | to_entries |
[
.[],
{key: "day", value: "Mo"},
{key: "start", value: $key},
{key: "age", value: ""},
{key: "extern", value: false},
{key: "duration", value: (($dict[$key].slots) * 15)}
] |
from_entries | del(.slots)