summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--meetup/after.html4
-rwxr-xr-xmeetup/gen_dates.sh55
2 files changed, 49 insertions, 10 deletions
diff --git a/meetup/after.html b/meetup/after.html
index 74d29ff..63230d0 100644
--- a/meetup/after.html
+++ b/meetup/after.html
@@ -1,4 +1,4 @@
<ul>
- <li>04.06.2011</li>
- <li>18.06.2011</li>
+ <li>06.06.2011</li>
+ <li>20.06.2011</li>
</ul>
diff --git a/meetup/gen_dates.sh b/meetup/gen_dates.sh
index 0457a39..d198c94 100755
--- a/meetup/gen_dates.sh
+++ b/meetup/gen_dates.sh
@@ -1,13 +1,52 @@
#!/bin/sh
-DOW=`date --date="next monday" +"%d"`
-DOW_TS=`date --date="next monday" +"%s"`
+# how far in the future
+LIMIT=3
+#DEBUG=1
+NEXT_FILE="next.html"
+AFTER_FILE="after.html"
-echo $DOW
-echo $DOW_TS
+DOW=`date +"%u"`
+if [ $DOW -eq 1 ]; then
+ DOM=`date +"%e"`
+ TS=`date +"%s"`
+else
+ DOM=`date --date="next monday" +"%e"`
+ TS=`date --date="next monday" +"%s"`
+fi
-NEXT_DOW_TS=$((DOW_TS + (7 * 24 * 3600)))
-NEXT_DOW=`date --date="@$NEXT_DOW_TS" +"%d"`
+MEETUPS=""
+CNT=0
+while true; do
+ if [ -n "$DEBUG" ]; then echo -n "check day($TS): "`date --date="@$TS" +"%d.%m.%Y"`; fi
-echo $NEXT_DOW
-echo $NEXT_DOW_TS
+ if [ $DOM -le 7 ] || ([ $DOM -ge 15 ] && [ $DOM -le 21 ]); then
+ if [ -n "$DEBUG" ]; then echo " -> ok"; fi
+ MEETUPS="$MEETUPS $TS"
+ CNT=$((CNT + 1))
+ if [ $CNT -ge $LIMIT ]; then
+ break;
+ fi
+ else
+ if [ -n "$DEBUG" ]; then echo ""; fi
+ fi
+ TS=$((TS + (7 * 24 * 3600)))
+ DOM=`date --date="@$TS" +"%e"`
+done
+
+set -- $MEETUPS
+NEXT=$1
+shift
+FUTURE=$@
+
+date --date="@$NEXT" +"%d.%m.%Y" > "$NEXT_FILE.new"
+echo "<ul>" > "$AFTER_FILE.new"
+for meetup in $FUTURE; do
+ echo " <li>"`date --date="@$meetup" +"%d.%m.%Y"`"</li>" >> "$AFTER_FILE.new"
+
+done
+echo "</ul>" >> "$AFTER_FILE.new"
+mv "$NEXT_FILE.new" "$NEXT_FILE"
+mv "$AFTER_FILE.new" "$AFTER_FILE"
+
+exit 0 \ No newline at end of file