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

Tim Roberts timr at gssc.UUCP
Tue Feb 12 04:56:02 AEST 1991


> int mdays[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

I have seen this construct in date solutions several times over the past
two weeks.  In my experience, it is almost always better to use an array of
the _accumulated_ days through the end of the month, rather than the actual
days in the month.  This generally lets one eliminate at least one loop.

For example:

int mdays[12] = { 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 };

-- 
timr at gssc.gss.com	Tim N Roberts, CCP	Graphic Software Systems
						Beaverton, OR

This is a very long palindrome. .emordnilap gnol yrev a si sihT



More information about the Comp.lang.c mailing list