#/bin/sh

NEWDATE=`zenity --calendar --title="Введите новую дату" --text="" --date-format="%m%d"`
if [ -z "$NEWDATE" ]; then
    echo The date will not be changed.
else
    echo $NEWDATE
fi

CURTIME=`date +%H:%M`

NEWTIME=`zenity --entry --title="Введите новое время" --text="Сейчас на
часах: $CURTIME" --entry-text="$CURTIME"`
if [ -z "$NEWTIME" ]; then
    echo The time will not be changed.
else
    echo $NEWTIME
fi

[ -z "$NEWDATE$NEWTIME" ] && exit 1

[ -z "$NEWTIME" ] && NEWTIME="$CURTIME"

NEWTIME=`echo "$NEWTIME" | awk -F: '{ print $1$2 }'`

echo $NEWTIME

if gksu "gnome-terminal -x date \"${NEWDATE-`date +%m%d`}$NEWTIME\""; then
    zenity --info --title="Ok" --text="The date/time has been changed."
else
    zenity --info --title="Failure" --text="The date/time was not changed."
fi
