date formats acceptable to the "date" command

Denys Vlasenko vda.linux at googlemail.com
Sat Jan 15 18:24:16 UTC 2011


On Friday 14 January 2011 13:47, David Collier wrote:
> In article <memo.20110114113746.14188A at postmaster+dexdyne.com.cix.co.uk>,
> from_busybox_maillist at dexdyne.com (David Collier) wrote:
> 
> > *From:* "David Collier" <from_busybox_maillist at dexdyne.com>
> > *To:* busybox at busybox.net
> > *CC:* jered at dexdyne.com
> > *Date:* Fri, 14 Jan 2011 11:37 +0000 (GMT Standard Time)
> > 
> > "big linux" date command seems to like a single format when you are
> > setting the date
> > 
> > that is [MMDDhhmm[[CC]YY][.ss]]
> > 
> > if I do "date --help" in busybox it says:
> > 
> > Recognized TIME formats:
> >         hh:mm[:ss]
> >         [YYYY.]MM.DD-hh:mm[:ss]
> >         YYYY-MM-DD hh:mm[:ss]
> >         [[[[[YY]YY]MM]DD]hh]mm[.ss]
> > 
> > which doesn't seem to allow for MMDDhhmmCCYY
> > 
> > however when I experiment with
> > 
> >    date 011410032011
> > 
> >    it all seems to work as desired.
> 
> rubbish - I screwed my tests
> 
> it worked          in 1.13.1, 
>      though it wasn't documented as an acceptable format
> it no longer works in 1.17.4
> 
> So I guess the help file is now telling the truth.
> 
> It seems a bit silly not to accept the only standard format as used by
> the coreutils version?

There seems to be no consensus between Unix-like systems on this:


http://developer.apple.com/library/mac/#documentation/darwin/reference/manpages/man1/date.1.html
DATE(1)                                  BSD General Commands Manual                                 DATE(1)
SYNOPSIS
     date [-jnu] [[[mm]dd]HH]MM[[cc]yy][.ss]

http://www.daemon-systems.org/man/date.1.html
DATE(1)                 NetBSD General Commands Manual                 DATE(1)
SYNOPSIS
     date [-ajnu] [-d date] [-r seconds] [+format] [[[[[[CC]yy]mm]dd]HH]MM[.SS]]

http://ss64.com/osx/date.html
Syntax
      date [-nu] [-r seconds] [+format] [[[[[cc]yy]mm]dd]hh]mm[.ss]

http://unixhelp.ed.ac.uk/CGI/man-cgi?date
DATE(1) 			 User Commands			       DATE(1)
SYNOPSIS
       date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]

"man date" on Fedora:
DATE(1)                          User Commands                         DATE(1)
SYNOPSIS
       date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]


From these five examples, two use [[cc]yy]mmddhhmm[.ss] and three
use mmddhhmm[[cc]yy][.ss] format.


But for another tool, touch, all manpages I was able to find uniformly say
that "touch -t DT" accepts DT = [[cc]yy]mmddhhmm[.ss] format on every Unix.
None of them use mmddhhmm[[cc]yy][.ss] for it.


I am torn here. From one POV, compatibility with "big Linux" date is good.
From another, mmddhhmm[[cc]yy][.ss] format is (a) stupid, (b) does not match
"touch -t" format, and (c) doesn't seem to be the universally accepted syntax
in wider Unix world.


-- 
vda


More information about the busybox mailing list