{"thread":{"id":"872","subject":"[PATCH] Fix cogito handling of timezones","startedAt":"2005-06-09T03:40:07Z","lastAt":"2005-06-09T14:20:29Z","messageCount":3,"participants":["Frank Sorenson","Petr Baudis"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"4749","messageId":"42A7BA17.5050707@tuxrocks.com","threadId":"872","inReplyTo":null,"subject":"[PATCH] Fix cogito handling of timezones","fromName":"Frank Sorenson","fromEmail":"frank@tuxrocks.com","sentAt":"2005-06-09T03:40:07Z","receivedAt":"2005-06-09T03:40:07Z","isPatch":true,"sender":{"key":"frank@tuxrocks.com","avatar":null},"body":"-----BEGIN PGP SIGNED MESSAGE-----\nHash: SHA1\n\nCurrent cogito behavior treats the timezone offset as if it's decimal,\nbut most zone offsets begin with a 0.  As a result, the computation\nin cg-Xlib uses the zone offset as an octal number.  -0700 looks like\n4 1/2 hours offset, rather than 7, and -0800 is an invalid octal\nnumber.\n\nThis patch fixes the behavior to strip off leading 0s.  It's ugly,\nbut it should produce the right values until someone with better\nbash scripting skills than I can fix it.\n\nSigned-off-by: Frank Sorenson <frank@tuxrocks.com>\n\ndiff --git a/cg-Xlib b/cg-Xlib\n- --- a/cg-Xlib\n+++ b/cg-Xlib\n@@ -6,6 +6,8 @@\n # This file provides a library containing common code shared with all the\n # Cogito programs.\n \n+shopt -s extglob\n+\n _cg_cmd=${0##*/}\n \n _git=${GIT_DIR:-.git}\n@@ -51,8 +53,12 @@ showdate () {\n \t[ \"$format\" ] || format=-R\n \tsec=${date[0]}; tz=${date[1]}\n \tif [ \"$has_gnudate\" ]; then\n- -\t        dtz=${tz/+/}\n- -\t\tlsec=$(($dtz / 100 * 3600 + $dtz % 100 * 60 + $sec))\n+\t\tsign=${tz%%[0-9]*}\n+\t\tsign=${sign:?+}\n+\t\tdtz=${tz/[+-]}\n+\t\tdtz=${dtz##*(0)}\n+\t\tdtz=${dtz:?0}\n+\t\tlsec=$(($sec + $dtz % 100 $sign $dtz / 100 * 3600))\n \t        pdate=\"$(date -ud \"1970-01-01 UTC + $lsec sec\" \"$format\" 2>/dev/null)\"\n \telse\n \t\t# FIXME: $format\n\n\nFrank\n- -- \nFrank Sorenson - KD7TZK\nSystems Manager, Computer Science Department\nBrigham Young University\nfrank@tuxrocks.com\n-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1.2.6 (GNU/Linux)\nComment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org\n\niD8DBQFCp7oXaI0dwg4A47wRAnOFAJ4jsaQodgxOr3gp8jMYhOxuJ98GFgCgnclC\nZd68hflXn8pV39zBF4YOlUc=\n=C+hn\n-----END PGP SIGNATURE-----\n"},{"id":"4772","messageId":"20050609082949.GC29665@pasky.ji.cz","threadId":"872","inReplyTo":"42A7BA17.5050707@tuxrocks.com","subject":"Re: [PATCH] Fix cogito handling of timezones","fromName":"Petr Baudis","fromEmail":"pasky@ucw.cz","sentAt":"2005-06-09T08:29:49Z","receivedAt":"2005-06-09T08:29:49Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Thu, Jun 09, 2005 at 05:40:07AM CEST, I got a letter\nwhere Frank Sorenson <frank@tuxrocks.com> told me that...\n> Current cogito behavior treats the timezone offset as if it's decimal,\n> but most zone offsets begin with a 0.  As a result, the computation\n> in cg-Xlib uses the zone offset as an octal number.  -0700 looks like\n> 4 1/2 hours offset, rather than 7, and -0800 is an invalid octal\n> number.\n> \n> This patch fixes the behavior to strip off leading 0s.  It's ugly,\n> but it should produce the right values until someone with better\n> bash scripting skills than I can fix it.\n> \n> Signed-off-by: Frank Sorenson <frank@tuxrocks.com>\n> \n> diff --git a/cg-Xlib b/cg-Xlib\n> --- a/cg-Xlib\n> +++ b/cg-Xlib\n> @@ -51,8 +53,12 @@ showdate () {\n>  \t[ \"$format\" ] || format=-R\n>  \tsec=${date[0]}; tz=${date[1]}\n>  \tif [ \"$has_gnudate\" ]; then\n> -\t        dtz=${tz/+/}\n> -\t\tlsec=$(($dtz / 100 * 3600 + $dtz % 100 * 60 + $sec))\n> +\t\tsign=${tz%%[0-9]*}\n> +\t\tsign=${sign:?+}\n> +\t\tdtz=${tz/[+-]}\n> +\t\tdtz=${dtz##*(0)}\n> +\t\tdtz=${dtz:?0}\n> +\t\tlsec=$(($sec + $dtz % 100 $sign $dtz / 100 * 3600))\n\nIt looks ok, but shouldn't this be\n+\t\tlsec=$(($sec + $dtz % 100 * 60 $sign $dtz / 100 * 3600))\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\n<Espy> be careful, some twit might quote you out of context..\n"},{"id":"4787","messageId":"42A8502D.4030508@tuxrocks.com","threadId":"872","inReplyTo":"20050609082949.GC29665@pasky.ji.cz","subject":"Re: [PATCH] Fix cogito handling of timezones","fromName":"Frank Sorenson","fromEmail":"frank@tuxrocks.com","sentAt":"2005-06-09T14:20:29Z","receivedAt":"2005-06-09T14:20:29Z","isPatch":true,"sender":{"key":"frank@tuxrocks.com","avatar":null},"body":"-----BEGIN PGP SIGNED MESSAGE-----\nHash: SHA1\n\nPetr Baudis wrote:\n\n> It looks ok, but shouldn't this be\n> +\t\tlsec=$(($sec + $dtz % 100 * 60 $sign $dtz / 100 * 3600))\n\nAh, yes, of course.  I see that Dan Holmsand has also sent a patch (3/6)\nto fix this.  I haven't tested his very much, but it looks like a\ncleaner and more comprehensive solution.  Sigh.\n\nFrank\n- -- \nFrank Sorenson - KD7TZK\nSystems Manager, Computer Science Department\nBrigham Young University\nfrank@tuxrocks.com\n-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1.2.6 (GNU/Linux)\nComment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org\n\niD8DBQFCqFAtaI0dwg4A47wRAlaEAJ0Ui38Yrwp7r0QUseI5/7n4kbnRaACfZBv0\nM5TClhJuvD2y7fz/Fm9pNes=\n=SOdU\n-----END PGP SIGNATURE-----\n"}]}