date/getdate.y: Relative days

Akim Demaille <[email protected]>
Newsgroups gmane.comp.gnu.utils
Message-ID <[email protected]>
I'm trying to find a means, given a week number, to find the date of
the Monday and Friday.  I was wondering if I could use GNU date to do
that straightforwardly instead of having to program this.

One first problem is how to get the n-th week of the year.  The
following seems to work:

  % LC_ALL=C date -d '2007-01-01 7 weeks'
  Mon Feb 19 00:00:00 CET 2007

but actually, it does not necessarily point to a Monday:

  % LC_ALL=C date -d '2006-01-01 7 weeks'
  Sun Feb 19 00:00:00 CET 2006



Then, the second issue, is how to use something like "next Friday", or
"last Monday" relatively to a date.

  % LC_ALL=C date -d '2006-01-01 next friday'
  Sun Jan  1 00:00:00 CET 2006
  (silently ignoring the "next Friday" part).

  % LC_ALL=C date -d 'next friday after 2006-01-01'
  date: invalid date `next friday after 2006-01-01'

Thanks in advance!
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.