# [COGITO PATCH] value too great for base (error token is "-0800")

2 messages from 2005-06-09 to 2005-06-10. Participants: Pavel Roskin, Petr Baudis.
Thread: https://gitlist.dev/t/887

## Pavel Roskin, 2005-06-09 21:40

Subject: [COGITO PATCH] value too great for base (error token is "-0800")
Message-ID: <1118353230.2825.10.camel@dv>
URL: https://gitlist.dev/e/1118353230.2825.10.camel%40dv

```
Hello!

The current cogito has problems with timezones that are too far from the
Greenwich meridian :-)

Bash interprets numbers beginning with 0 as octals.  Therefore, we need
to strip leading zeroes or zeroes following "-".  But if we get too
zealous and strip all digits, we'll need to restore one 0.  I tried to
write for sed portably, so I avoided some optimizations, such as
s/^-\?$/0/

Signed-off-by: Pavel Roskin <proski@gnu.org>

diff --git a/cg-Xlib b/cg-Xlib
--- a/cg-Xlib
+++ b/cg-Xlib
@@ -65,7 +65,7 @@ showdate () {
 	[ "$format" ] || format=-R
 	sec=${date[0]}; tz=${date[1]}
 	if [ "$has_gnudate" ]; then
-	        dtz=${tz/+/}
+	        dtz=$(echo $tz | sed 's/^+//;s/^0*//;s/^-0*/-/;s/^$/0/;s/^-$/0/')
 		lsec=$(($dtz / 100 * 3600 + $dtz % 100 * 60 + $sec))
 	        pdate="$(date -ud "1970-01-01 UTC + $lsec sec" "$format" 2>/dev/null)"
 	else

-- 
Regards,
Pavel Roskin


```

## Petr Baudis, 2005-06-10 22:19

Subject: Re: [PATCH] Fix cogito handling of timezones
Message-ID: <20050610221936.GA22111@pasky.ji.cz>
URL: https://gitlist.dev/e/20050610221936.GA22111%40pasky.ji.cz
In-Reply-To: <1118353230.2825.10.camel@dv>

```
  Hello,

  FYI, from the contestants for the octal fix, I've chosen to take Dan's
solution - not that I'd think it's the best, but it's simple and
mainly I'm taking other Dan's changes and I don't like solving
conflicts.

> +	local secs=$1 tzhours=${2:0:3} tzmins=${2:0:1}${2:3} format=$3
> +	# bash doesn't like leading zeros
> +	[ "${tzhours:1:1}" = 0 ] && tzhours=${2:0:1}${2:2:1}
> +	secs=$((secs + tzhours * 3600 + tzmins * 60))

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
<Espy> be careful, some twit might quote you out of context..

```
