Re: [PATCH 1/1] hwclock.c, hwclock.8.in: new --show format

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

 



On Wed, Feb 17, 2016 at 11:54:32AM +0100, Karel Zak wrote:
> On Tue, Feb 16, 2016 at 09:02:39PM -0500, J William Piggott wrote:
> > 
> > On 02/16/2016 05:29 AM, Karel Zak wrote:
> > > On Thu, Feb 11, 2016 at 07:48:40PM -0500, J William Piggott wrote:
> > >> -		lt = localtime(&hwctime.tv_sec);
> > >> -		strftime(ctime_now, sizeof(ctime_now), format, lt);
> > >> -		printf(_("%s and %06d microseconds\n"), ctime_now, (int)hwctime.tv_usec);
> > >> +		struct tm lt;
> > >> +		int zhour, zmin;
> > >> +
> > >> +		lt = *localtime(&hwctime.tv_sec);
> > >> +		zhour = - timezone / 60 / 60;
> > >> +		zmin = abs(timezone / 60 % 60);
> > >> +		printf(_("%4d-%.2d-%.2d %02d:%02d:%02d.%06d%+02d:%02d\n"),
> > >> +		       lt.tm_year + 1900, lt.tm_mon + 1, lt.tm_mday, lt.tm_hour,
> > >> +		       lt.tm_min, lt.tm_sec, (int)hwctime.tv_usec, zhour, zmin);
> > > 
> > > Some notes:
> > > 
> > > * what's wrong with strftime? 
> > 
> > Why use resources on strftime when 8601 prints directly?
> > 
> > While it can do other formatting, I see strftime's main purpose as
> > converting tm numbers into strings like: January, Monday, etc.
> 
>  It does more things for you, see lt.tm_year + 1900, lt.tm_mon + 1,
>  calculation of the time zone hours, timezone minutes...

Ah, now I see that strftime is not able to produce timezone hh:mm.
Well, compose the string without strftime seems better in this case.
Sorry.

    Karel


-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux