bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] Gawk manual: 9.1.5 Time Functions, strftime([format [, ti


From: Andrew J. Schorr
Subject: Re: [bug-gawk] Gawk manual: 9.1.5 Time Functions, strftime([format [, timestamp [, utc-flag]]])
Date: Sat, 2 Feb 2013 12:45:38 -0500
User-agent: Mutt/1.5.21 (2010-09-15)

Hi Hermann,

On Sat, Feb 02, 2013 at 12:25:48AM -0200, Hermann Peifer wrote:
> > awk --lint 'BEGIN{ print strftime(1359771050)}'
> awk: cmd. line:1: warning: `strftime' is a gawk extension
> awk: cmd. line:1: warning: strftime: received non-string first argument
> 1359771050

I think you are misinterpreting the manual.  It says:

`strftime([FORMAT [, TIMESTAMP [, UTC-FLAG]]])'
     Format the time specified by TIMESTAMP based on the contents of
     the FORMAT string and return the result.  It is similar to the
     function of the same name in ISO C.  If UTC-FLAG is present and is
     either nonzero or non-null, the value is formatted as UTC
     (Coordinated Universal Time, formerly GMT or Greenwich Mean Time).
     Otherwise, the value is formatted for the local time zone.  The
     TIMESTAMP is in the same format as the value returned by the
     `systime()' function.  If no TIMESTAMP argument is supplied,
     `gawk' uses the current time of day as the timestamp.  If no
     FORMAT argument is supplied, `strftime()' uses the value of
     `PROCINFO["strftime"]' as the format string (*note Built-in
     Variables::).  The default string value is
     `"%a %b %e %H:%M:%S %Z %Y"'.  This format string produces output
     that is equivalent to that of the `date' utility.  You can assign
     a new value to `PROCINFO["strftime"]' to change the default format.

If you supply no arguments at all, then the default PROCINFO["strftime"]
will be used.  If you supply any arguments at all, the first one must
be the FORMAT.

bash-4.1$ gawk 'BEGIN {print strftime()}'
Sat Feb  2 12:44:37 EST 2013
bash-4.1$ gawk 'BEGIN {PROCINFO["strftime"] = "%F %T"; print strftime()}'
2013-02-02 12:45:01

Regards,
Andy



reply via email to

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