git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Holmsand <holmsand@gmail.com>
To: git@vger.kernel.org
Cc: Petr Baudis <pasky@ucw.cz>
Subject: [PATCH 3/6] Make showdate use "Linus format"
Date: Thu, 09 Jun 2005 13:19:30 +0200	[thread overview]
Message-ID: <42A825C2.1060302@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 433 bytes --]

This makes showdate use the same date format as
git-rev-list --pretty, and gives some speedup. It might also
be more portable.

Note that this changes the calling convention: the previous
version used seconds from $1, but timezone from the global
variable $date. cg-mkpatch is modified to the new way.

Also fixes bash's belief that number literals starting with
zero are octal.

Signed-off-by: Dan Holmsand <holmsand@gmail.com>
---

[-- Attachment #2: 3-showdate.patch.txt --]
[-- Type: text/plain, Size: 1421 bytes --]

 cg-Xlib    |   18 ++++++++----------
 cg-mkpatch |    2 +-
 2 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/cg-Xlib b/cg-Xlib
--- a/cg-Xlib
+++ b/cg-Xlib
@@ -60,19 +60,17 @@ stat () {
 }
 
 showdate () {
-	date="$1"
-	format="$2"
-	[ "$format" ] || format=-R
-	sec=${date[0]}; tz=${date[1]}
+	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))
 	if [ "$has_gnudate" ]; then
-	        dtz=${tz/+/}
-		lsec=$(($dtz / 100 * 3600 + $dtz % 100 * 60 + $sec))
-	        pdate="$(date -ud "1970-01-01 UTC + $lsec sec" "$format" 2>/dev/null)"
+		[ "$format" ] || format="+%a %b %-d %H:%M:%S %Y $2"
+		LANG=C date -ud "1970-01-01 UTC + $secs sec" "$format"
 	else
-		# FIXME: $format
-	        pdate="$(date -u -r ${date[0]} 2>/dev/null)"
+		[ "$format" ] || format="+%a %b %d %H:%M:%S %Y $2"
+		date -u -r $secs "$format"
 	fi
-	echo "${pdate/+0000/$tz}"
 }
 
 # Usage: tree_timewarp [--no-head-update] DIRECTION_STR ROLLBACK_BOOL BASE BRANCH
diff --git a/cg-mkpatch b/cg-mkpatch
--- a/cg-mkpatch
+++ b/cg-mkpatch
@@ -52,7 +52,7 @@ showpatch () {
 		case "$key" in
 		"author"|"committer")
 			date=(${rest#*> })
-			pdate="$(showdate $date)"
+			pdate="$(showdate ${date[*]})"
 			[ "$pdate" ] && rest="${rest%> *}> $pdate"
 			echo $key $rest >>$header
 			;;

         reply	other threads:[~2005-06-09 12:32 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 ` Dan Holmsand [this message]
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             ` [PATCH] Fix cogito handling of timezones Frank Sorenson
2005-06-09  8:29               ` 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=42A825C2.1060302@gmail.com \
    --to=holmsand@gmail.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).