bug-coreutils
[Top][All Lists]
Advanced

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

Re: date function


From: Bob Proulx
Subject: Re: date function
Date: Sun, 14 Mar 2004 13:51:17 -0700
User-agent: Mutt/1.3.28i

Thank you for taking the time to submit a report.  However I think you
are confused by the documentation.  :-)

address@hidden wrote:
> I think there is a wrong algorithm in your date function when using
> the %C argument for displaying the current century. your algorithm
> (year divided by 100 and truncated to an integer) gives the 20th
> century for the year 2004.  but obviously that's not correct, so
> there has to be added a "+ 1" to your algorithm.

Here is what the standards documents say about it.

  http://www.unix-systems.org/single_unix_specification_v2/xcu/date.html

  Century (a year divided by 100 and truncated to an integer) as a
  decimal number [00-99].

The algorithm is explicit that %C is the two digit century part of the
current year.  This is not the same as the 20th or 21st century
definition.  It is instead used to slice up the date into component
parts.

For example, this should return the current year.

  date +%C%y
  2004

Bob




reply via email to

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