Article View: comp.unix.programmer
Article #259Re: Need (today's date - 2 WORKING days) [was: Need (today's date + [1-7]]
From: Bernd Felsche
Date: Sun, 02 Aug 1992 11:09
Date: Sun, 02 Aug 1992 11:09
45 lines
2271 bytes
2271 bytes
In <1992Jul29.031546.26997@bnd2.bnd.oz.au>
johnw@bnd2.bnd.oz.au (John Warburton) writes:
>From article <1992Jul28.072025.13886@cssc-syd.tansu.com.au>, by colinl@cssc-syd.tansu.com.au (Colin Lynch):
>> bernie@metapro.DIALix.oz.au (Bernd Felsche) writes:
Please stop attributing this post to me. It's not my fault,
even if it is right. Some bloke called Colin owns it.
>> ...The most reliable way to do this is to first convert the current
>> date/time into a time_t type ("time_t" is defined in the system header file
>> <time.h>, and is basically a long containing the number of seconds since the
>> start of 01 Jan 1970 on most systems):
>>
>> #include <time.h>
>>
>> time_t current_time;
>>
>> current_time = time((time_t *)0);
>>
>> Having done this, just set a macro for the length (in seconds) of one
>> day:
>>
>> #define ONE_DAY ((60) * (60) * (24))
>>
>> From here, you can get the value for any day you want. For example, the
>> value for two days' into the future would be:
>>
>> two_days_ahead = current_time + (ONE_DAY * 2);
>>
>> Hope this is helpful. Cheers, Colin.
>Ok, that all works, but how do I get the day that was 2 WORKING (Mon..Fri) days
>ago?
>I can't seem to find any sort of general purpose way of doing this. Any
>pointers?
See ctime(3) and refer to struct tm. I'll leave the rest as an exercise.
--
+-----+ Bernd Felsche _--_|\ #include <std/disclaimer.h>
| | | | MetaPro Systems Pty Ltd / \ bernie@metapro.DIALix.oz.au
| | | | 328 Albany Highway, X_.--._/ Fax: +61 9 472 3337
|m|p|s| Victoria Park, Western Australia 6100 v Phone: +61 9 362 9355
Technical Details
Message-ID:
<1992Aug2.110937.16961@metapro.DIALix.oz.au>Path:
arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!uniwa!DIALix!metapro!bernieReferences:
<1992Jul28.072025.13886@cssc-syd.tansu.com.au> <1992Jul29.031546.26997@bnd2.bnd.oz.au>Show Full Headers
Complete Article Headers
Newsgroups: comp.unix.programmer,comp.unix.questions Path: arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!uniwa!DIALix!metapro!bernie From: bernie@metapro.DIALix.oz.au (Bernd Felsche) Subject: Re: Need (today's date - 2 WORKING days) [was: Need (today's date + [1-7]] Message-ID: <1992Aug2.110937.16961@metapro.DIALix.oz.au> Organization: MetaPro Systems, Perth, Western Australia References: <1992Jul28.072025.13886@cssc-syd.tansu.com.au> <1992Jul29.031546.26997@bnd2.bnd.oz.au> Date: Sun, 2 Aug 92 11:09:37 GMT Lines: 45