Bug 30451

Summary: command '/bin/date -f' not working as described
Product: Base System Reporter: Randall Raemon <rlr>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.2-RELEASE   
Hardware: Any   
OS: Any   

Description Randall Raemon 2001-09-09 04:40:01 UTC
	

   The man page, and the help usage for the /bin/date command
   describe a way to parse a date format using the -f parameter.

   Specifically:

      usage: date [-nu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ... 
            [-f fmt date | [[[[[cc]yy]mm]dd]HH]MM[.ss]] [+format]

   This implies that '-f' takes 2 parameters, the format and the
   date to be parsed.

Fix: 

I eyeballed the code in /usr/src/bin/date/date.c It looks like the
   code takes only 1 parameter, so there is some kind of mismatch
   between what the code is doing, and what the usage/manpage are
   saying. By default, the code wins...
How-To-Repeat: 
	

   For example:

      date -u -j -f '%s' 1000000000

   should return a date of Sun 9 Sep 2001 about 0205 GMT

   Instead, I get back:

Warning: Ignoring 10 extraneous characters in date string (1000000000)
Sun Sep  9 03:20:06 UTC 2001  (which happens to be the current time)

   Aside, I was curious as to when the clock/odometer rolled over.
   It led me to try out the date command parameters...
Comment 1 ulf 2001-09-09 09:05:25 UTC
I can not reproduce the problem as described in the "How-To-Repeat":

playtoy ulf bin/date > date -u -j -f '%s' 1000000000
Sun Sep  9 01:46:40 UTC 2001

The command is as cut+paste'ed from the PR. As to the code only taking 
one argument that is incorrect. The second argument given to setthetime 
is *argv, which in this case would be "1000000000". I tried this on 
4.4-RC/-Stable.
Comment 2 dd freebsd_committer freebsd_triage 2001-09-10 11:51:00 UTC
State Changed
From-To: open->closed

Problem fixed in later releases.