From danielt@knast.server-king.de  Fri Jan 30 14:33:04 2004
Return-Path: <danielt@knast.server-king.de>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 79BEF16A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 30 Jan 2004 14:33:04 -0800 (PST)
Received: from knast.server-king.de (knast.server-king.de [217.19.167.129])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 11F8A43D53
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 30 Jan 2004 14:33:03 -0800 (PST)
	(envelope-from danielt@knast.server-king.de)
Received: from knast.server-king.de (danielt@localhost.server-king.de [127.0.0.1])
	by knast.server-king.de (8.12.10/8.12.10) with ESMTP id i0UMX1nt032288
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO)
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 30 Jan 2004 23:33:01 +0100 (CET)
	(envelope-from danielt@knast.server-king.de)
Received: (from danielt@localhost)
	by knast.server-king.de (8.12.10/8.12.10/Submit) id i0UMX19E032287;
	Fri, 30 Jan 2004 23:33:01 +0100 (CET)
	(envelope-from danielt)
Message-Id: <200401302233.i0UMX19E032287@knast.server-king.de>
Date: Fri, 30 Jan 2004 23:33:01 +0100 (CET)
From: Danijel Tasov <dt@vosat.de>
Reply-To: Danijel Tasov <dt@vosat.de>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: strange date -v results
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         62134
>Category:       bin
>Synopsis:       strange date -v results
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jan 30 14:40:00 PST 2004
>Closed-Date:    Sat Jan 31 13:18:35 PST 2004
>Last-Modified:  Sat Jan 31 13:18:35 PST 2004
>Originator:     Danijel Tasov
>Release:        FreeBSD 5.2-RELEASE i386
>Organization:
>Environment:
System: FreeBSD knast 5.2-RELEASE FreeBSD 5.2-RELEASE #0: Sat Jan 17 15:55:17 CET 2004 knarf@knast:/usr/obj/usr/src/sys/KLAGENFURT i386


>Description:
        Current date: Fri Jan 30 23:31:26 CET 2004
        
        for i in 1 2 3
        do
          date -v2004y -v${i}m -y17d +%Y-%m-%d
        done

        This results in the following output:
        
        2004-01-17
        2004-03-17
        2004-03-17

        instead of

        2004-01-17
        2004-02-17
        2004-03-17

	This bug apears in 5.2-RELEASE and 4.9-RELEASE.

>How-To-Repeat:
  	Run the script above.
>Fix:
	Sorry. :-/

>Release-Note:
>Audit-Trail:

From: Danijel Tasov <dt@vosat.de>
To: FreeBSD-gnats-submit@FreeBSD.org, freebsd-bugs@FreeBSD.org
Cc:  
Subject: Re: bin/62134: strange date -v results
Date: Fri, 30 Jan 2004 23:59:06 +0100

 > for i in 1 2 3
 > do
 >   date -v2004y -v${i}m -y17d +%Y-%m-%d
 > done                    ^
 
 for i in 1 2 3
 do
   date -v2004y -v${i}m -v17d +%Y-%m-%d
 done
 
 Sorry for the Typo.
                                                -DaTa-
 
 -- 
 Jabber: data@jabber.pilgerer.org ICQ: 84074839 e-Mail: dt@vosat.de
 http://wiki.pilgerer.org/ - Die Kommunikations- und Kooperations-   | () ASCII
 plattform fuer Unix-Fans und alle die es werden wollen.  Macht mit! | /\ RIBBON
 # "zieh deinen xterm groesser und fertig..." - Spaceelk                         

From: Edwin Groothuis <edwin@mavetju.org>
To: Danijel Tasov <dt@vosat.de>
Cc: FreeBSD-gnats-submit@FreeBSD.org
Subject: Re: bin/62134: strange date -v results
Date: Sat, 31 Jan 2004 13:30:43 +1100

 man date says:
 	Adjust (i.e., take the current date and display the result
 	of the adjustment; not actually set the date) the second,
 	minute, hour, month day, week day, month or year according
 	to val.  If val is preceded with a plus or minus sign, the
 	date is adjusted forwards or backwards according to the
 	remaining string, otherwise the relevant part of the date
 	is set.  The date can be adjusted as many times as required
 	using these flags.  Flags are processed in the order given.
 
 	[...]
 
 	When the date is adjusted to a specific value that doesn't
 	actually exist (for example March 26, 1:30 BST 2000 in the
 	Europe/London timezone), the date will be silently adjusted
 	forwards in units of one hour until it reaches a valid time.
 	When the date is adjusted to a specific value that occurs
 	twice (for example October 29, 1:30 2000), the resulting
 	timezone will be set so that the date matches the earlier
 	of the two times.
 
 So what you're doing is, on januari 30th or 31st:
 
     for i in 1 2 3; do date -v2004y -v${i}m -v17d +%Y-%m-%d; done
 
 Loop i=1:
     step 1. current date is 2004-01-31
     step 2. -v2004y: set current year to 2004, date will become 2004-01-31
     step 3. -v1m: set current month to 1, date will become 2004-01-31
     step 4. -v17d: set current day to 17, date will become 2004-01-17
 
 Loop i=2:
     step 1. current date is 2004-01-31
     step 2. -v2004y: set current year to 2004, date will become 2004-01-31
     step 3. -v2m: set current month to 2, date will become 2004-02-31
 	    Unfortunatly this date doesn't exist, so it takes the next
 	    best value and date will become 2004-03-01.
     step 4. -v17d: set current day to 17, date will become 2004-03-17
 
 Loop i=3:
     step 1. current date is 2004-01-31
     step 2. -v2004y: set current year to 2004, date will become 2004-01-31
     step 3. -v3m: set current month to 2, date will become 2004-03-31
     step 4. -v17d: set current day to 17, date will become 2004-03-17
 
 Same problem will happen when you add the 4th month to the list.
 
 
 So the right syntax would be:
     for i in 1 2 3; do date -v17d -v${i}m -v2004y +%Y-%m-%d; done
 
 -- 
 Edwin Groothuis      |            Personal website: http://www.mavetju.org
 edwin@mavetju.org    |          Weblog: http://weblog.barnet.com.au/edwin/

From: Danijel Tasov <dt@vosat.de>
To: Edwin Groothuis <edwin@mavetju.org>
Cc: FreeBSD-gnats-submit@FreeBSD.org
Subject: Re: bin/62134: strange date -v results
Date: Sat, 31 Jan 2004 14:07:53 +0100

 On Sat, Jan 31, 2004 at 01:30:43PM +1100, Edwin Groothuis wrote:
 > 	When the date is adjusted to a specific value that doesn't
 > 	actually exist (for example March 26, 1:30 BST 2000 in the
 > 	Europe/London timezone), the date will be silently adjusted
 > 	forwards in units of one hour until it reaches a valid time.
 > 	When the date is adjusted to a specific value that occurs
 > 	twice (for example October 29, 1:30 2000), the resulting
 > 	timezone will be set so that the date matches the earlier
 > 	of the two times.
 > 
 > Loop i=2:
 >     step 1. current date is 2004-01-31
 >     step 2. -v2004y: set current year to 2004, date will become 2004-01-31
 >     step 3. -v2m: set current month to 2, date will become 2004-02-31
 > 	    Unfortunatly this date doesn't exist, so it takes the next
 > 	    best value and date will become 2004-03-01.
 >     step 4. -v17d: set current day to 17, date will become 2004-03-17
 
 Thank you for your answer. My mistake was, that I assumed that
 the execution of all -v flags is atomic. I've read the quoted
 paragraph from date(1), but I would never come to the idea, that
 the -v flags are executed one after another.
 
 Can somebody close this PR please?
 
                                                -DaTa-
 
 -- 
 Jabber: data@jabber.pilgerer.org ICQ: 84074839 e-Mail: dt@vosat.de
 http://wiki.pilgerer.org/ - Die Kommunikations- und Kooperations-   | () ASCII
 plattform fuer Unix-Fans und alle die es werden wollen.  Macht mit! | /\ RIBBON
 # "zieh deinen xterm groesser und fertig..." - Spaceelk                         
State-Changed-From-To: open->closed 
State-Changed-By: edwin 
State-Changed-When: Sat Jan 31 13:18:17 PST 2004 
State-Changed-Why:  
Closed on submitters request 

http://www.freebsd.org/cgi/query-pr.cgi?pr=62134 
>Unformatted:
