Bug 21039

Summary: date -v31d -v08m -v2000y
Product: Base System Reporter: Dietmar Tanke <dtanke>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.1-RELEASE   
Hardware: Any   
OS: Any   

Description Dietmar Tanke 2000-09-04 21:10:00 UTC
Date adjustment using the -v option seems not work for any date with
the 31th day of a month. Two examples. First one with a good result
and the second leads to an unexpected error. Is it a bug?

dtanke$ date -v30d -v08m -v2000y 
Wed Aug 30 21:27:24 CEST 2000

dtanke$ date -v31d -v08m -v2000y 
31d: Cannot apply date adjustment

This example with "31" works well with 4.1 RELEASE.

dtanke$ date  -jf "%d.%m.%Y" 31.08.2000
Do  31 Aug 2000 21:38:15 CEST

Fix: 

I am no programmer, sorry.
How-To-Repeat: Same results with 2.2.8, 3.2, 4.0 and 4.1 RELEASE.
Comment 1 Paul Herman 2000-09-04 21:46:16 UTC
On Mon, 4 Sep 2000, Dietmar Tanke wrote:

> >Description:
> Date adjustment using the -v option seems not work for any date with
> the 31th day of a month. Two examples. First one with a good result
> and the second leads to an unexpected error. Is it a bug?
> 
> dtanke$ date -v30d -v08m -v2000y 
> Wed Aug 30 21:27:24 CEST 2000

The order of the "-v"s are important.

bash-2.03$ date -v8m -v31d -v2000y
Thu Aug 31 22:45:03 CEST 2000

Try it next month and it'll work no matter what the order.  :-)

-Paul.
Comment 2 Brian Somers freebsd_committer freebsd_triage 2000-09-04 22:55:25 UTC
State Changed
From-To: open->closed

As Paul says, the -v options are processed in the order given 
(as mentioned in the man page).  Doing things most-significant 
first will make things work for you.