Strftime's %C and %y formats versus wide-ranging tm_year valu es

Ken Pizzini tz. at explicate.org
Sat Oct 16 05:38:17 UTC 2004


On Fri, Oct 15, 2004 at 12:02:52PM -0700, Paul Eggert wrote:
> ! 	pt = result + sprintf(result,
> ! 		ASCTIME_FMT,
>   		wn, mn,
>   		timeptr->tm_mday, timeptr->tm_hour,
> ! 		timeptr->tm_min, timeptr->tm_sec);

I don't know if we care, but some pre-C89 implementations of
sprintf() returned a char* (a copy of the first argument, IIRC)
rather than the count of bytes written.  If portability to
such archaic systems is considered to be worth the bother then
this code fragment should read:
    	(void)sprintf(result,
    		ASCTIME_FMT,
    		wn, mn,
    		timeptr->tm_mday, timeptr->tm_hour,
    		timeptr->tm_min, timeptr->tm_sec);
    	pt = result + strlen(result);


		--Ken Pizzini



More information about the tz mailing list