From owner-freebsd-questions Mon Nov 4 17: 3:29 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B8A0737B401 for ; Mon, 4 Nov 2002 17:03:27 -0800 (PST) Received: from mailsrv.otenet.gr (mailsrv.otenet.gr [195.170.0.5]) by mx1.FreeBSD.org (Postfix) with ESMTP id AB71043E6E for ; Mon, 4 Nov 2002 17:03:26 -0800 (PST) (envelope-from keramida@freebsd.org) Received: from gray.sea.gr (patr530-a222.otenet.gr [212.205.215.222]) by mailsrv.otenet.gr (8.12.6/8.12.6) with ESMTP id gA513Mcd019599; Tue, 5 Nov 2002 03:03:23 +0200 (EET) Received: from gray.sea.gr (gray [127.0.0.1]) by gray.sea.gr (8.12.6/8.12.6) with ESMTP id gA512hGA026572; Tue, 5 Nov 2002 03:03:21 +0200 (EET) (envelope-from keramida@freebsd.org) Received: (from keramida@localhost) by gray.sea.gr (8.12.6/8.12.6/Submit) id gA4JAIhA079102; Mon, 4 Nov 2002 21:10:18 +0200 (EET) (envelope-from keramida@freebsd.org) Date: Mon, 4 Nov 2002 21:10:18 +0200 From: Giorgos Keramidas To: Claus Fonnesbek Nielsen Cc: freebsd-questions@freebsd.org Subject: Re: date command bug? Message-ID: <20021104191018.GA76580@gray.sea.gr> References: <6184B203EF3D3C49B86625828FED723E01ECA509@VESTMB201A.tdk.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6184B203EF3D3C49B86625828FED723E01ECA509@VESTMB201A.tdk.dk> Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On 2002-11-04 10:38, Claus Fonnesbek Nielsen wrote: > > guf@loghost01% date -v31d -v10m -v2002y > 31d: Cannot apply date adjustment > usage: date [-jnu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ... > > [-f fmt date | [[[[[cc]yy]mm]dd]HH]MM[.ss]] [+format] > > Why... there is 31 days in October, so is it a BUG As the manpage mentions, the order of the date adjustments is significant. It appears that date(1) attempts to make the adjustments in steps, one little adjustment every time a -v option is encountered. Now, we are in November, and the -v31m adjustment is wrong. But if you pass -v10m as the first option, the month adjustment happens first and then -v31d is meaningful for the ``adjusted month value''. : keramida@gray[21:01]/home/keramida$ date -j -v31d -v10m -v2002y : 31d: Cannot apply date adjustment : usage: date [-jnu] [-d dst] [-r seconds] [-t west] : [-v[+|-]val[ymwdHMS]] ... : [-f fmt date | [[[[[cc]yy]mm]dd]HH]MM[.ss]] [+format] : keramida@gray[21:01]/home/keramida$ date -j -v10m -v31d -v2002y : Thu Oct 31 21:02:01 EET 2002 > It works with the following command: > > guf@loghost01% date -v30d -v10m -v2002y -v+1d > Thu Oct 31 10:35:55 CET 2002 Because -v+1d comes after -v10m. Putting -v+1d before -v10m wraps around to Oct 1 today (since it's November and the month doesn't have 31 days): : keramida@gray[21:04]/home/keramida$ date -j -v30d -v+1d -v10m -v2002y : Tue Oct 1 21:05:07 EEST 2002 I hope this helps a bit, Giorgos. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message