bug-bash
[Top][All Lists]
Advanced

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

feature request: printf %(%s)T


From: Greg Wooledge
Subject: feature request: printf %(%s)T
Date: Tue, 22 Nov 2011 16:53:38 -0500
User-agent: Mutt/1.4.2.3i

This is a feature request, rather than a bug.  Bash 4.2's printf command
has a lovely %(datefmt)T feature that allows it to print out formatted
timestamps using the underlying operating system's strftime(3) routine.
It even allows bash to print the current time, or the time the current
shell was invoked.

However, the power of this feature is tied to the underlying strftime()
call, and not all of those have the same feature set.  There is one
particular feature that is in high demand: the ability to print the
current time in epoch format (seconds since 1970-01-01 00:00 GMT),
which is what date +%s does, or what bash's printf %(%s)T -1 does, on
platforms where %s is implemented.  But it would be extremely useful
to be able to do this on *all* platforms.

So: it would be useful if bash could interpret %(%s)T specially, and
simply emit the time value as a base 10 number, rather than calling
localtime() or strftime() or any other formatting.  This would enable
date +%s style functionality on platforms where it is not available
through any other means; and on platforms where strftime() can do that,
it would avoid some library calls.



reply via email to

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