home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / c / 18446 < prev    next >
Encoding:
Internet Message Format  |  1992-12-16  |  1.4 KB

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