changeset 5:ba844bcb8b5e

Support generate slide that next day of the week
author Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
date Thu, 30 Jan 2014 22:00:36 +0900
parents ab0287707334
children f6d65d2a806f
files new_slide.sh today_slide.sh
diffstat 2 files changed, 41 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/new_slide.sh	Thu Jan 30 22:00:36 2014 +0900
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+slide_root_dirname="slides"
+date_format="%Y%m%d"
+slide_name="slide.md"
+
+# function
+
+dirname_from_day_of_the_week() {
+
+    case $1 in
+        "mon") week_of_day="next Mon." ;;
+        "tue") week_of_day="next Tue." ;;
+        "wed") week_of_day="next Wed." ;;
+        "thu") week_of_day="next Thu." ;;
+        "fri") week_of_day="next Fri." ;;
+        "sat") week_of_day="next Sat." ;;
+        "sun") week_of_day="next Sun." ;;
+
+        *) week_of_day=""   # default is empty value, it's today
+    esac
+
+    if [[  $(uname) == Darwin ]]; then
+        command="gdate"     # --date option is supported by GNU date
+    else
+        command="date"
+    fi
+
+    ${command} --date="${week_of_day}" +"${date_format}"
+}
+
+# main
+
+slide_dirname=`dirname_from_day_of_the_week ${1}`
+dir_full_path="${slide_root_dirname}/${slide_dirname}"
+slide_full_path="${dir_full_path}/${slide_name}"
+
+mkdir -p ${dir_full_path}
+touch ${slide_full_path}
+echo ${slide_full_path}
+
--- a/today_slide.sh	Thu Jan 30 21:38:26 2014 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-#!/bin/sh
-
-root_dirname="slides"
-date_format="%Y%m%d"
-slide_name="slide.md"
-
-dirname=`date +${date_format}`
-dir_full_path="${root_dirname}/${dirname}"
-slide_full_path="${root_dirname}/${dirname}/${slide_name}"
-
-mkdir -p ${dir_full_path}
-touch ${slide_full_path}
-echo ${slide_full_path}