bug-bash
[Top][All Lists]
Advanced

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

Re: RFE: printf '%(fmt)T' prints current time by default


From: Dan Douglas
Subject: Re: RFE: printf '%(fmt)T' prints current time by default
Date: Wed, 14 Nov 2012 06:52:56 -0600
User-agent: KMail/4.8.3 (Linux/3.4.6-pf+; KDE/4.8.3; x86_64; ; )

On Wednesday, November 14, 2012 11:00:18 AM Clark WANG wrote:
> In ksh:
> 
> $ printf '%(%F %T)T\n'
> 2012-11-14 10:57:26
> $
> 
> In bash:
> 
> $ printf '%(%F %T)T\n'
> 1970-01-01 08:00:00
> $
> 
> I think the ksh behavior is makes more sense so can we use the current time
> as the default?
> 
> -Clark

I agree that a null or empty argument as equivalent to -1 is a better default. 
"0" is identical to the current behavior for empty/unset, so no functionality 
is lost.

Additionally, an empty format in ksh is equivalent to the date(1) default for 
the current locale. So, LC_TIME=C; [[ $(printf '%()T') == "$(date)" ]] is 
true.

I imagine all the functionality ksh gets basically for free with libast tm.h 
functions is totally out of the question, if all there is to work from is libc 
strptime and friends. Having "date -d" essentially built in is handy. :/
--
Dan Douglas



reply via email to

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