need "yy-ddd-hh:mm:ss ==> (time_t) clock" converter

Stephen Clamage steve at taumet.com
Sat Feb 23 03:13:48 AEST 1991


In article <1991Feb18.133937.28469 at fivegl.co.nz>, hugh at fivegl.co.nz (Hugh Grierson) writes:
| In article <2323 at stsci.EDU> ansok at stsci.EDU (Gary Ansok) writes:
| >In article <6586 at gssc.UUCP> timr at gssc.UUCP (Tim Roberts) writes:
| >>> int mdays[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
| 
| >>int mdays[12] = { 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 };
|
| >suppose it's possible), the benefits of the first in readability and
| >maintainability far outweigh any speed gained by the second.
| 
| Maintainability????  How often *do* you have to change the number
| of days in a month?????  (Sept 1752 notwithstanding)

But what about when the program isn't working?  As Kernighan and Plauger
point out in "The Elements of Programming Style", it is easy to look at
the first version and know it is right ("Thirty days hath September," etc).
This allows you to move on to look for errors elsewhere.

Quick Quiz: is the second version (31, 59, ...) quoted in this posting
correct?  Did I change any of the numbers accidently (or on purpose)?
To find out, you have to do some arithmetic.
-- 

Steve Clamage, TauMetric Corp, steve at taumet.com



More information about the Comp.lang.c mailing list