diff options
author | Gerhard Brauer <gerbra@archlinux.de> | 2009-06-29 17:59:24 +0200 |
---|---|---|
committer | Dieter Plaetinck <dieter@plaetinck.be> | 2009-06-29 21:35:17 +0200 |
commit | 3b1be38c4f6b5e661b06cecdd187d10cdcc4982d (patch) | |
tree | 4b444884dc32a3243e4ace0651bd59f1aeb2101b /src | |
parent | 2dd328ef66f1def146323e7ed7c4c6e4c8e25e7f (diff) |
Modified timesetting procedure again
With our current code we get problems when the user want to set datetime
manually in our dialog. Revisiting last changes i see: it's a bad thing
to force any timesetting based on a *selected* timezone in an still UTC
environment.
So the easiest way (and i hope the last change on this!) is:
a) user selected a timezone
b) we set this timezonefile to /etc/localtime
c) Now we ask: is your hwclock on UTC or localtime?
c) UTC BIOSclock user now have both correct system and hw time.
d) For localtime users we must re-read the hwclock into our new
timezone, cause copy'ing above timezone file has recalculated the
systemtime to a false time.
I've tested these commit on my PC, both with hwclock on UTC and
localtime, also with manual setting and via ntp(date) in the aif dialog.
Signed-off-by: Gerhard Brauer <gerbra@archlinux.de>
Diffstat (limited to 'src')
-rw-r--r-- | src/core/libs/lib-misc.sh | 7 | ||||
-rw-r--r-- | src/core/libs/lib-ui-interactive.sh | 22 |
2 files changed, 13 insertions, 16 deletions
diff --git a/src/core/libs/lib-misc.sh b/src/core/libs/lib-misc.sh index b10d835..e96e4d2 100644 --- a/src/core/libs/lib-misc.sh +++ b/src/core/libs/lib-misc.sh @@ -104,7 +104,6 @@ cleanup_runtime () # $1 UTC or localtime (hardwareclock) # $2 direction (systohc or hctosys) -# $3 selected TIMEZONE (optional) dohwclock() { # TODO: we probably only need to do this once and then actually use adjtime on next invocations infofy "Resetting hardware clock adjustment file" @@ -117,11 +116,7 @@ dohwclock() { if [ "$1" = "UTC" ]; then hwclock --$2 --utc else - if [ ! "$3"x == "x" ]; then - local ret=$(TZ=$3 hwclock --$2 --localtime) # we need the subshell so that TZ does not set in this shell - else - hwclock --$2 --localtime - fi + hwclock --$2 --localtime fi } diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index e66403a..3774707 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -94,20 +94,28 @@ interactive_timezone () { ask_timezone || return 1 TIMEZONE=$ANSWER_TIMEZONE infofy "Setting Timezone to $TIMEZONE" + if [ -n "$TIMEZONE" -a -e "/usr/share/zoneinfo/$TIMEZONE" ] + then + # This changes probably also the systemtime (UTC->$TIMEZONE)! + # localtime users will have a false time after that! + /bin/rm -f /etc/localtime + /bin/cp "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime + fi } - interactive_time () { # utc or localtime? ask_option UTC "Clock configuration" "Is your hardware clock in UTC or local time? UTC is recommended" required "UTC" " " "localtime" " " || return 1 HARDWARECLOCK=$ANSWER_OPTION - [ -e /etc/localtime ] && rm -f /etc/localtime + # To avoid a false time for localtime users after above + # we must re-read the hwclock value again, but now into the + # correct timezone. + [ "$HARDWARECLOCK" == "localtime" ] && dohwclock $HARDWARECLOCK hctosys NEXTITEM= while true; do - dohwclock $HARDWARECLOCK hctosys $TIMEZONE - current=$(TZ=$TIMEZONE date) + current=$(date) default=no [ -n "$NEXTITEM" ] && default="$NEXTITEM" #TODO: only propose if network ok @@ -138,12 +146,6 @@ interactive_time () { fi [ "$ANSWER_OPTION" = return ] && break done - - if [ "$TIMEZONE" != "" -a -e "/usr/share/zoneinfo/$TIMEZONE" ] - then - /bin/rm -f /etc/localtime - /bin/cp "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime - fi } |