git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Fix cogito handling of timezones

From
FSFrank Sorenson <frank@tuxrocks.com>
Date
Jun 9, 2005, 03:40 UTC
Message-ID
<42A7BA17.5050707@tuxrocks.com>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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
@@ -6,6 +6,8 @@
 # This file provides a library containing common code shared with all the
 # Cogito programs.
 
+shopt -s extglob
+
 _cg_cmd=${0##*/}
 
 _git=${GIT_DIR:-.git}
@@ -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))
 	        pdate="$(date -ud "1970-01-01 UTC + $lsec sec" "$format" 2>/dev/null)"
 	else
 		# FIXME: $format


Frank
- -- 
Frank Sorenson - KD7TZK
Systems Manager, Computer Science Department
Brigham Young University
frank@tuxrocks.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCp7oXaI0dwg4A47wRAnOFAJ4jsaQodgxOr3gp8jMYhOxuJ98GFgCgnclC
Zd68hflXn8pV39zBF4YOlUc=
=C+hn
-----END PGP SIGNATURE-----
Next: Petr Baudis
Message 1 of 3 in “Fix cogito handling of timezones”
  1. Fix cogito handling of timezonesFrank Sorenson, Jun 9, 2005
  2. Petr BaudisJun 9, 2005
  3. Frank SorensonJun 9, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.