3 if [ "$REQUEST_METHOD" = POST ]; then
4 id="${PATH_INFO%/newdate}"; id="${id#/}"
6 month="$(POST month |grep -m 1 -xE '[0-9]{4}-(0[1-9]|1[012])')"
7 todremove="$(POST todremove |grep -m 1 -xE '[0-9]+')"
8 DBM "$file" set title "$(POST title)"
9 DBM "$file" set description "$(POST description)"
10 DBM "$file" set dates "$(
11 for date in $(seq 1 $(POST_COUNT date)); do
15 | grep -xE '^[0-9]{4}-((01|03|05|07|08|10|12)-([012][0-9]|3[01])|(04|06|09|11)-([012][0-9]|30)|02-[012][0-9])$' \
18 DBM "$file" set todall "$(
19 for todcount in $(seq 1 $(POST_COUNT todstart)); do
20 [ "$todremove" -eq "$todcount" ] 2>&- && continue;
21 todstart="$(POST todstart "$todcount")"
22 todend="$(POST todend "$todcount")"
23 [ "${todstart%:??}" -lt "${todend%:??}" -o "${todstart%:??}" -eq "${todend%:??}" -a "${todstart#*:}" -lt "${todend#*:}" ] \
25 && { printf '%02i:%02i-%02i:%02i\n' "${todstart%:??}" "${todstart#*:}" "${todend%:??}" "${todend#*:}"; }\
26 || { [ "${todstart%:??}" -ge 0 -a "${todstart#*:}" -ge 0 ] 2>&- && printf '%02i:%02i-\n' "${todstart%:??}" "${todstart#*:}"; }
27 done |grep -xE '^([01][0-9]|2[0-3]):([0-5][0-9])-(([01][0-9]|2[0-3]):([0-5][0-9]))?$' |sort -u
29 if [ "$(POST cancel)" = cancel ]; then
32 elif [ "$(POST addtime)" = global ]; then
33 DBM "$file" append todall "${BR}-"
34 REDIRECT "$_BASE$PATH_INFO${month:+?month=}${month}"
35 elif [ "$month" ]; then
36 REDIRECT "$_BASE$PATH_INFO?month=$month"
38 REDIRECT "$_BASE$PATH_INFO"
41 id="${PATH_INFO%/newdate}"; id="${id#/}"
43 month="$(GET month |grep -m1 -xE '[0-9]{4}-(0[1-9]|1[012])' || date +%Y-%m)"
44 Y="${month%-*}"; m="${month#*-}"; Y=${Y#0}; m=${m#0};
45 [ "$m" = 1 ] && prev=$(printf '%04i-%02i' $((Y - 1)) 12) || prev=$(printf '%04i-%02i' $Y $((m - 1)))
46 [ "$m" = 12 ] && next=$(printf '%04i-%02i' $((Y + 1)) 01) || next=$(printf '%04i-%02i' $Y $((m + 1)))
47 dates="$(DBM "$file" get dates)"
48 days="$(printf %s "$dates" |sed -E "/^${month}-/!d; s;^.*-([0-9]{2})$;\1;g")"
49 additional="$(printf %s "$dates" |sed -E "/^${month}-/d;")"
50 todall="$(DBM "$file" get todall)"
52 yield_page "$(pagename "$id")" "newdate" <<-EOF
55 [input name=title value="$(DBM "$file" get title |HTML)" placeholder="Title"]
56 [textarea name=description placeholder="Description" . $(DBM "$file" get description |HTML)]
58 $(printf '[hidden "date" "%s"]' $additional)
59 [submit "month" "$prev" Previous Month]
60 $(w_month multiple date "$month" $days)
61 [submit "month" "$next" Next Month]
62 [hidden "month" "$month"]
65 [label .todstart Start Time (optional):
67 [label .todend End Time (optional):
69 $(c=0; for time in ${todall:--}; do
72 <input name="todstart" value="%s" placeholder="HH:MM" list="dlist_timeofday"
73 pattern="^(0?\[0-9\]|1\[0-9\]|2\[0-3\]):(\[0-5\]\[0-9\])$"/>
74 <input name="todend" value="%s" placeholder="HH:MM" list="dlist_timeofday"
75 pattern="^(0?\[0-9\]|1\[0-9\]|2\[0-3\]):(\[0-5\]\[0-9\])$"/>
76 [submit "todremove" "%i" -]
77 ' "${time%-*}" "${time#*-}" "${c}"
79 [submit "addtime" "global" + Add time option]
81 [submit "cancel" "cancel" Cancel]
82 [submit "post" "post" Post Event]