summaryrefslogtreecommitdiff
path: root/src/core/libs/lib-ui.sh
diff options
context:
space:
mode:
authorDieter Plaetinck <dieter@plaetinck.be>2008-12-07 15:55:55 +0100
committerDieter Plaetinck <dieter@plaetinck.be>2008-12-07 15:55:55 +0100
commit7500ef53598f2ee2c128bd9b93d5c94b1aa7b6e9 (patch)
treeadcfb41ad6627ff7b899e66a5de299b5da1d581f /src/core/libs/lib-ui.sh
parentcc258490000e54a1897d7905fe5d642cced5779e (diff)
refactored/cleanup datetime/timezone stuff
Diffstat (limited to 'src/core/libs/lib-ui.sh')
-rw-r--r--src/core/libs/lib-ui.sh28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh
index 1ca87d5..9191998 100644
--- a/src/core/libs/lib-ui.sh
+++ b/src/core/libs/lib-ui.sh
@@ -137,6 +137,28 @@ ask_checklist ()
+ask_datetime ()
+{
+ if [ "$var_UI_TYPE" = dia ]
+ then
+ # display and ask to set date/time
+ dialog --calendar "Set the date.\nUse <TAB> to navigate and arrow keys to change values." 0 0 0 0 0 2> $ANSWER || return 1
+ local _date="$(cat $ANSWER)" # form like: 07/12/2008
+ dialog --timebox "Set the time.\nUse <TAB> to navigate and up/down to change values." 0 0 2> $ANSWER || return 1
+ local _time="$(cat $ANSWER)" # form like: 15:26:46
+ echo "date: $_date time: $_time" >$LOG
+
+ # DD/MM/YYYY hh:mm:ss -> MMDDhhmmYYYY.ss (date default format, set like date $ANSWER_DATETIME) Not enabled because there is no use for it i think.
+ # ANSWER_DATETIME=$(echo "$_date" "$_time" | sed 's#\(..\)/\(..\)/\(....\) \(..\):\(..\):\(..\)#\2\1\4\5\3\6#g')
+ # DD/MM/YYYY hh:mm:ss -> YYYY-MM-DD hh:mm:ss ( date string format, set like date -s $ANSWER_DATETIME)
+ ANSWER_DATETIME="$(echo "$_date" "$_time" | sed 's#\(..\)/\(..\)/\(....\) \(..\):\(..\):\(..\)#\3-\2-\1 \4:\5:\6#g')"
+ elif [ "$var_UI_TYPE" = cli ]
+ ask_string "Enter date [YYYY-MM-DD hh:mm:ss]"
+ ANSWER_DATETIME=$ANSWER_STRING
+ fi
+}
+
+
# TODO: we should have a wrapper around this function that keeps trying until the user entered a valid numeric?, maybe a wrapper that wraps all functions
# ask for a number.
# $1 question
@@ -191,6 +213,12 @@ ask_string ()
}
+ask_timezone () # TODO: how to do this in dia?
+{
+ ANSWER_TIMEZONE=`tzselect`
+}
+
+
# ask a yes/no question.
# $1 question
# $2 default answer yes/no (optional)