home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!news.funet.fi!news.cs.tut.fi!pjh
- From: pjh@cs.tut.fi (Haavisto Petri)
- Newsgroups: comp.lang.c
- Subject: Re: Finding the number of days between two dates
- Date: 16 Dec 1992 06:11:56 GMT
- Organization: Tampere University of Technology
- Lines: 25
- Distribution: world
- Message-ID: <1gmhbcINNsi3@cs.tut.fi>
- References: <1fsk16INNhn0@cs.tut.fi>
- NNTP-Posting-Host: vuoripyy.cs.tut.fi
-
- In article <1fsk16INNhn0@cs.tut.fi> pjh@cs.tut.fi (Haavisto Petri) writes:
- >
- >I need to write a standard conforming implementation of a function
- >that computes the number of days between two given dates. For example,
- >given Dec. 6, 1992 and Dec. 24, 1992, the function should return 18.
-
- I have now received several responses both by email and in the net.
- After a lot of pain and agony I managed to get the thing working.
-
- It is clearly best to convert the dates to Julian day numbers and then
- subtract. The functions time(), mktime(), and difftime() are not
- guaranteed to (and will not) cover wide ranges of dates.
-
- The pain and agony resulted from a compiler bug (Microsoft C v6.00)
- which made the Julian day inverse function given in "Numerical Recipes
- in C" to subtly fail (those interested are referred to comp.std.c).
-
- Thank you very much to everyone who replied.
-
- Petri Haavisto pjh@cs.tut.fi
- Signal Processing Laboratory tel: +358 31 161 849
- Tampere University of Technology fax: +358 31 161 857
- P.O.B. 553
- SF-33101, Tampere
- FINLAND
-