diff options
author | Dieter Plaetinck <dieter@plaetinck.be> | 2008-12-10 10:52:27 +0100 |
---|---|---|
committer | Dieter Plaetinck <dieter@plaetinck.be> | 2008-12-10 10:52:27 +0100 |
commit | 2f06e0ade3223c8087f5ad714a360ab3a761e05f (patch) | |
tree | 3fc0e833cb19ea078c2229dca5912154c39b55a2 /src/core/libs | |
parent | 04aed5ddd8b300b1521a89437d4c99756283c4a8 (diff) |
datetime cleanup
Diffstat (limited to 'src/core/libs')
-rw-r--r-- | src/core/libs/lib-ui.sh | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh index f45824b..ae2acbc 100644 --- a/src/core/libs/lib-ui.sh +++ b/src/core/libs/lib-ui.sh @@ -152,24 +152,8 @@ 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 ] - then - ask_string "Enter date [YYYY-MM-DD hh:mm:ss]" - ANSWER_DATETIME=$ANSWER_STRING - fi + [ "$var_UI_TYPE" = dia ] && { _dia_ask_datetime "$@" ; return $? ; } + [ "$var_UI_TYPE" = cli ] && { _cli_ask_datetime "$@" ; return $? ; } } @@ -299,6 +283,22 @@ _dia_ask_checklist () } +_dia_ask_datetime () +{ + # 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')" +} + + _dia_ask_number () { #TODO: i'm not entirely sure this works perfectly. what if user doesnt give anything or wants to abort? @@ -450,6 +450,13 @@ _cli_ask_number () } +_cli_ask_datetime () +{ + ask_string "Enter date [YYYY-MM-DD hh:mm:ss]" + ANSWER_DATETIME=$ANSWER_STRING +} + + _cli_ask_option () { #TODO: strip out color codes |