Date: Mon, 4 Nov 2002 21:10:18 +0200 From: Giorgos Keramidas <keramida@freebsd.org> To: Claus Fonnesbek Nielsen <cnlsn@tdc.dk> Cc: freebsd-questions@freebsd.org Subject: Re: date command bug? Message-ID: <20021104191018.GA76580@gray.sea.gr> In-Reply-To: <6184B203EF3D3C49B86625828FED723E01ECA509@VESTMB201A.tdk.dk> References: <6184B203EF3D3C49B86625828FED723E01ECA509@VESTMB201A.tdk.dk>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2002-11-04 10:38, Claus Fonnesbek Nielsen <cnlsn@tdc.dk> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021104191018.GA76580>