Bug 18253

Summary: date command does not take -v31d (31st day of month) option
Product: Base System Reporter: paulchef <paulchef>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description paulchef 2000-04-27 12:00:01 UTC
heimdall % date -v31d -v1m -v1999y
31d: Cannot apply date adjustment
usage: date [-nu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHM]] ...
            [-f fmt date | [[[[yy]mm]dd]HH]MM[.ss]] [+format]
heimdall %
Comment 1 mellon 2000-04-27 15:25:25 UTC
On Thu, Apr 27, 2000 at 03:52:16AM -0700, paulchef@starwon.com.au wrote:
> heimdall % date -v31d -v1m -v1999y
> 31d: Cannot apply date adjustment

date -v1m -v31d -v1999y 

will work. This is because the day value is checked for validity against
the current month, which has not yet been changed to January.

I don't know that this is a bug. If fixing it is desirable, walking
the 'vary' structure in vary_apply() in src/bin/date/vary.c needs to
be changed to first apply year adjustments, then month adjustments, etc.
and not in the order of command line arguments.

-- 
Anatoly Vorobey,
mellon@pobox.com http://pobox.com/~mellon/
"Angels can fly because they take themselves lightly" - G.K.Chesterton
Comment 2 Brian Somers freebsd_committer freebsd_triage 2000-05-09 11:43:02 UTC
State Changed
From-To: open->closed

It's vital that the -v options are processed in order, otherwise it is 
impossible to do something like ``date -v3m -v-1d'' to find out the last 
day in February.  The man page explicitly says 

The date can be adjusted as many times as required using these 
flags.  Flags are processed in the order given.