git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Frank Sorenson <frank@tuxrocks.com>
To: Git Mailing List <git@vger.kernel.org>, Petr Baudis <pasky@ucw.cz>
Subject: [PATCH] Fix cogito handling of timezones
Date: Wed, 08 Jun 2005 21:40:07 -0600	[thread overview]
Message-ID: <42A7BA17.5050707@tuxrocks.com> (raw)

-----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-----

         reply	other threads:[~2005-06-09  3:36 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-09 21:40 [COGITO PATCH] value too great for base (error token is "-0800") Pavel Roskin
2005-06-09 11:19 ` [PATCH 3/6] Make showdate use "Linus format" Dan Holmsand
2005-06-09  9:19   ` [ANNOUNCE] Cogito-0.11.3 Petr Baudis
2005-06-09 10:10     ` Konstantin Antselovich
2005-06-09 13:07       ` Dan Holmsand
2005-06-09 20:55         ` Chris Wright
2005-06-09 21:06           ` Chris Wright
2005-06-09  3:40             ` Frank Sorenson [this message]
2005-06-09  8:29               ` [PATCH] Fix cogito handling of timezones Petr Baudis
2005-06-09 14:20                 ` Frank Sorenson
2005-06-10 22:19               ` Petr Baudis
2005-06-10 22:59   ` [PATCH 3/6] Make showdate use "Linus format" Petr Baudis
2005-06-11  8:28     ` Dan Holmsand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=42A7BA17.5050707@tuxrocks.com \
    --to=frank@tuxrocks.com \
    --cc=git@vger.kernel.org \
    --cc=pasky@ucw.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).