Re: [PATCH 4/4] test: give unique timestamps to messages

Subject: Re: [PATCH 4/4] test: give unique timestamps to messages

Date: Mon, 09 Dec 2013 09:18:42 +0800

To: Tomi Ollila, notmuch@notmuchmail.org

Cc:

From: David Bremner


Tomi Ollila <tomi.ollila@iki.fi> writes:

>>      if [ -z "${template[date]}" ]; then
>> -	template[date]="Fri, 05 Jan 2001 15:43:57 +0000"
>> +	template[date]=$(date -Ru -d@$((978709437 - gen_msg_cnt)))
>
> I am afraid this is not portable (although not sure). This could work:
>
> _s=$((3599 - gen_msg_cnt))
> template[date]="Fri, 05 Jan 2001 15:$((_s / 60)):$((_s % 60)) +0000"
>

How about this instead?

diff --git a/test/test-lib.sh b/test/test-lib.sh
index 792e477..22a4d7f 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -356,7 +356,8 @@ generate_message ()
     fi
 
     if [ -z "${template[date]}" ]; then
-	template[date]=$(date -Ru -d@$((978709437 - gen_msg_cnt)))
+	template[date]=$(TZ=UTC printf "%(%a, %d %b %Y %T %z)T\n" \
+			$((978709437 - gen_msg_cnt)))
     fi
 
     additional_headers=""

Thread: