Weekly edition Kernel Security Distributions Contact Us Search Archives Calendar Subscribe Write for LWN LWN.net FAQ Sponsors

# Linux at the end of the world (our 2012 predictions)

## Linux at the end of the world (our 2012 predictions)

Posted Jan 9, 2012 16:09 UTC (Mon) by jzbiciak (✭ supporter ✭, #5246)
In reply to: Linux at the end of the world (our 2012 predictions) by dlang
Parent article: Linux at the end of the world (our 2012 predictions)

I personally doubt mortgages are computed with time_t directly, for similar reasons to why there's so much interest in decimal floating point.

Mortgages are generally built around months. It seems to me the three pieces of information you're going to most likely need to compute an amortization schedule are:

• Days in the a given month
• Days in the a given year
• Day number within a given month/year

That gives you enough information to compute interest compounding given partial first/last months (ie. a prorated month at either end to align with a fixed payment schedule), and slightly varying interest month to month to compensate for varying month sizes. And, even then that's not strictly necessary, since I believe you are also allowed to just take the annual rate and divide it by 12 to get a monthly rate. I think I've seen it done both ways.

That sort of math is a P.I.T.A. with time_t. Quick: How do you get from one month to the next with time_t? How do you find days in month? Days in year?

It's slightly better with struct tm, but only slightly. This is where it gets a little more interesting, since you could bounce back and forth between struct tm and time_t. But, that seems unnecessary because I can't see how it'd buy you much. With fairly simple logic, you can figure out days-in-month once you have the correct year without ever touching a time_t.

All that said, it would surprise me at all if the date management was built around these low level UNIX structures. It seems more likely, as others have said, that there's hand-rolled date code floating around in many cases. The rest probably uses date management libraries that also don't use time_t directly.