Re: [PATCH] Fix cogito handling of timezones
- From
Petr Baudis <pasky@ucw.cz>
- Date
- Jun 9, 2005, 08:29 UTC
- Message-ID
- <20050609082949.GC29665@pasky.ji.cz>
- In-Reply-To
- <42A7BA17.5050707@tuxrocks.com>
Dear diary, on Thu, Jun 09, 2005 at 05:40:07AM CEST, I got a letter where Frank Sorenson <frank@tuxrocks.com> told me that...
Show 27 quoted lines
> Current cogito behavior treats the timezone offset as if it's decimal,
> but most zone offsets begin with a 0. As a result, the computation
> in cg-Xlib uses the zone offset as an octal number. -0700 looks like
> 4 1/2 hours offset, rather than 7, and -0800 is an invalid octal
> number.
>
> This patch fixes the behavior to strip off leading 0s. It's ugly,
> but it should produce the right values until someone with better
> bash scripting skills than I can fix it.
>
> Signed-off-by: Frank Sorenson <frank@tuxrocks.com>
>
> diff --git a/cg-Xlib b/cg-Xlib
> --- a/cg-Xlib
> +++ b/cg-Xlib
> @@ -51,8 +53,12 @@ showdate () {
> [ "$format" ] || format=-R
> sec=${date[0]}; tz=${date[1]}
> if [ "$has_gnudate" ]; then
> - dtz=${tz/+/}
> - lsec=$(($dtz / 100 * 3600 + $dtz % 100 * 60 + $sec))
> + sign=${tz%%[0-9]*}
> + sign=${sign:?+}
> + dtz=${tz/[+-]}
> + dtz=${dtz##*(0)}
> + dtz=${dtz:?0}
> + lsec=$(($sec + $dtz % 100 $sign $dtz / 100 * 3600))It looks ok, but shouldn't this be + lsec=$(($sec + $dtz % 100 * 60 $sign $dtz / 100 * 3600))
-- Petr "Pasky" Baudis Stuff: http://pasky.or.cz/ <Espy> be careful, some twit might quote you out of context..