View Single Post

   
  #2 (permalink)  
Old 05-11-2008, 09:41 PM
loki harfagr
 
Posts: n/a
Default Re: OT: util for relative date?

On Sun, 11 May 2008 11:30:51 -0700, William Hunt wrote:

> i'm looking for a util which, given an integer argument N, can print the
> date of the day N days ago. example:
> $ day
> 2008/05/11
> $ day -1
> 2008/05/10
> $ day -12
> 2008/04/30
>
> I can't figure how to get date(1) '--date=...' to do this for me. (well
> actually I can but it is simply too ugly for words :*) Does someone want
> to smack me with a Clue ? I suppose I should just do it in C and be
> done, but the idea seems so elementary that someone surely must have
> this already ?
>
> Thanks in advance for any comments,


You didn't say your reasons why you wouldn't
use the 'fuzzy' date like:

$ date --date "yesterday"
Sat May 10 20:43:46 CEST 2008
$ date --date "now"
Sun May 11 20:43:55 CEST 2008
$ date --date "2 days ago"
Fri May 9 20:44:06 CEST 2008
$ date --date "next week"
Sun May 18 20:44:20 CEST 2008
Reply With Quote