bug-sh-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: DATE set broken


From: Bob Proulx
Subject: Re: DATE set broken
Date: Sat, 9 Nov 2002 11:43:31 -0700
User-agent: Mutt/1.4i

Please follow up to the list and not to me personally unless it is
private.  I forwarded your message to the list and am following up to
it.  It is a team effort.

Barnes, Brian <address@hidden> [2002-11-07 11:48:37 -0600]:
> 
> I just used the MAN page and found it most confusing.

I notice that other commercial systems explain the date with this in
the man page.

    The numeric argument is interpreted left to right in two-digit
    pairs as follows:

              mm   Month number [01-12].
              dd   Day number in the month [01-31].
              hh   Hour number (24-hour system) [00-23].
              mm   Minute number [00-59].
              yy   Last two digits of the year number
                   [70-99, 00-69 (1970-1999, 2000-2069)].  If omitted,
                   the current year is used.

Nothing similar is present in the date man page.  It is explained in
the "Setting the time" section of the info page.

> It will accept just about any "reasonable" time/date format and spit out the
> ctime for it. 

That is the function of the -s option.  To accept most human readable
time syntaxes and operate on them.

> Following is 100% of the documentation for setting a date:
>  -s, --set=STRING    set time described by STRING

  info date

Actually, the documentation refers you to the -d option.

  `-s DATESTR'
  `--set=DATESTR'
       Set the time and date to DATESTR,  See `-d' above.

For the -d option there are lots of examples.  Please see the section
titled "Examples of date".

> Since this usage (date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]) does
> not contain the -s(ET), it must be this one, "date [OPTION]... [+FORMAT]".
> So, we have a +FORMAT and a STRING as clues to the usage. But, "FORMAT
> controls the output" so that won't work. All we have to work with is STRING.
> I tried a bunch which it didn't like. 

I am sorry but I was unable to understand your meaning here.  That
sentence did not parse for me.

> >This is from the info page.
> >     date [OPTION]... [+FORMAT]
> >     date [-u|--utc|--universal] [ MMDDhhmm[[CC]YY][.ss] ]
> >What is misleading about either of those?
> 
> FORMAT applies only to showing the time. There is zero information about
> setting it except that it is a string. Not much to go on. And, your process
> is not reversible. Any fully specified format you can print should be
> acceptable as input.

Okay, to be explicit, let's break apart [ MMDDhhmm[[CC]YY][.ss] ].

  MM -- Month number (01-12)
  DD -- Day number (00-31)
  hh -- Hour number (00-23)
  mm -- Minute number (00-59)
  CCYY -- Optional Century, recommended, Year number (Ex: 2002)
  .ss -- optional seconds (00-59)

Try this:

  date +%m%d%H%M%Y

That prints out the date in the format needed to set the date.

Try this:

  date "$(date +%m%d%H%M%Y)"

That should set the date to the same minute as it is currently.

But really the old date format is not as intuitive to people as the
human readable version.  Therefore the -s option.

Try this:

  date -s $(date)

Here date will print out a human readable string which is then parsed
by the -s option and will set the date accordingly.

> The info page, which some systems do not have, does have much more to go on.

The info page with the full documentation should be installed.  If it
is not then please complain and file a bug against whomever installed
one but not the other.  It is really not fair to say that while
documentation was provided by the project that someone else did not
include it.

Bob




reply via email to

[Prev in Thread] Current Thread [Next in Thread]