Subject: Re: date feature request
To: Lubomir Sedlacik <>
From: matthew sporleder <>
List: netbsd-users
Date: 11/14/2006 09:59:35
On 11/14/06, Lubomir Sedlacik <> wrote:
> On Tue, Nov 14, 2006 at 12:12:23AM -0600, John Darrow wrote:
> > The main question is what option letter to use?  -R (like suggested
> > above)?  -N (a common "don't actually do it, just show me what would
> > happen" option letter)?  Something else?  Is there any prior art for
> > this?  Does POSIX or anything else have anything to say?  What color
> > should we paint the bike shed? ;-)
> POSIX says nothing about it:
> both FreeBSD and OpenBSD provide this functionality with the -j option:

You can also do most of this stuff portably with awk.
Here's an easy example of yesterday: (tested on netbsd and solaris)

echo|awk 'BEGIN { d = systime() - 86400; } END { print strftime("%c", d) }'


From AWK(1)
   Time Functions
     This awk provides the following two functions for obtaining time stamps
     and formatting them:

             Returns the value of time in seconds since the start of Unix
             Epoch (Midnight, January 1, 1970, Coordinated Universal Time).
             See also time(3).

     strftime([format [, timestamp]])
             Formats the time timestamp according to the string format.
             timestamp should be in same form as value returned by systime().
             If timestamp is missing, current time is used. If format is miss-
             ing, a default format equivalent to the output of date(1) would
             be used. See the specification of ANSI C strftime(3) for the for-
             mat conversions which are supported.