From 42742c4fa29c9a335f9b8ebfbc860590467b7c8e Mon Sep 17 00:00:00 2001 From: Gerhard Brauer Date: Thu, 25 Jun 2009 20:05:18 +0200 Subject: Fixed timesetting for hwclock localtime users When we set system time from the BIOS clock via hwclock we must honor the timezone the user previous selected during interactive_time(). After boot we are in an UTC environment. If we now - for localtime users - parse hwclcock value to systemtime, then we get later a false systemtime when copying the TZ file to /etc/localtime. Changing /etc/localtime always recalculate the time according to the timezone. Signed-off-by: Gerhard Brauer --- src/core/libs/lib-misc.sh | 9 +++++++-- src/core/libs/lib-ui-interactive.sh | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/core/libs/lib-misc.sh b/src/core/libs/lib-misc.sh index 1e8df8e..aa00dc6 100644 --- a/src/core/libs/lib-misc.sh +++ b/src/core/libs/lib-misc.sh @@ -104,6 +104,7 @@ 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" @@ -116,7 +117,11 @@ dohwclock() { if [ "$1" = "UTC" ]; then hwclock --$2 --utc else - hwclock --$2 --localtime + 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 fi } @@ -124,4 +129,4 @@ target_configure_initial_keymap_font () { [ -n "$var_KEYMAP" ] && sed -i "s/^KEYMAP=.*/KEYMAP=\"$var_KEYMAP\"/" ${var_TARGET_DIR}/etc/rc.conf [ -n "$var_CONSOLEFONT" ] && sed -i "s/^CONSOLEFONT=.*/CONSOLEFONT=\"$var_CONSOLEFONT\"/" ${var_TARGET_DIR}/etc/rc.conf -} \ No newline at end of file +} diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index 812753e..ae3ccd2 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -106,8 +106,8 @@ interactive_time () { NEXTITEM= while true; do - dohwclock $HARDWARECLOCK hctosys - current=`date` + dohwclock $HARDWARECLOCK hctosys $TIMEZONE + current=$(TZ=$TIMEZONE date) default=no [ -n "$NEXTITEM" ] && default="$NEXTITEM" #TODO: only propose if network ok -- cgit v1.2.3-54-g00ecf