goble@cs.washington.edu (Brian Goble) (06/26/91)
I need some C code to maniuplate dates. I need to be able to compute the number of days between 2 dates (or maybe compute the date to a "serial" date like Excel does--number of days from 1/1/1900). I also need to be able to determine what day of the week a given day is (e.g. Tuesday). Any code or pointers to code would be much appreciated...thanx. Brian Goble | goble@wolf.cs.washington.edu
mathew@mantis.co.uk (Giving C News a *HUG*) (06/26/91)
goble@cs.washington.edu (Brian Goble) writes: > I need some C code to maniuplate dates. I need to be able to compute > the number of days between 2 dates difftime() /* Divide by 60*60*24 to get the difference in days */ > (or maybe compute the date to a > "serial" date like Excel does--number of days from 1/1/1900). time() /* Divide by 60*60*24 to get the number of days since 1970-01-01 */ > I also need to be able to determine what day of the week a given day > is (e.g. Tuesday). gmtime() /* Look at the tm_wday field of the returned structure */ > Any code or pointers to code would be much appreciated...thanx. Try looking up the standard "time.h" library calls in the manual? mathew
rsimpkin@javelin.sim.es.com (Roger Simpkins) (06/27/91)
goble@cs.washington.edu (Brian Goble) writes: >I need some C code to maniuplate dates. I need to be able to compute >the number of days between 2 dates (or maybe compute the date to a >"serial" date like Excel does--number of days from 1/1/1900). >I also need to be able to determine what day of the week a given day >is (e.g. Tuesday). ALL of the above functions contained in any ANSI C compiler. Try looking at time(), difftime(), asctime() and you may have some sucess.
HARVEY@SLACVM.SLAC.STANFORD.EDU (06/27/91)
NONE OF THE FUNCTIONS YOU MENTIONED WILL COMPUTE DAYS BETWEEN DATES THAT GO PAST 1 MONTH. I HAD THIS PROBLEM A COUPLE OF MONTHS AGO AND I RECEIVED A LOT OF SOURCE FROM THE NETWORK. IF YOU EMAIL ME DIRECTLY I WILL DIG OUT THE SOURCE FOR YOU. HARVEY@SLACVM