[COGITO PATCH] value too great for base (error token is "-0800")
- From
- Pavel Roskin <proski@gnu.org>
- Date
- Jun 9, 2005, 21:40 UTC
- Message-ID
- <1118353230.2825.10.camel@dv>
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