* Day Number
@ 2002-07-29 5:40 dbisnath
0 siblings, 0 replies; 2+ messages in thread
From: dbisnath @ 2002-07-29 5:40 UTC (permalink / raw)
To: gcc-help
[-- Attachment #1: Type: text/plain, Size: 294 bytes --]
Hi,
How does one get the day number e.g. Sunday = 0, Monday = 1 etc ?
I want to test the day number against a variable e.g.
if ( dayNumber == DaynumberVar )
do x,y,z
Thanks
---------------------------------------
This message was sent using Postaci Webmail. (http://www.trlinux.com)
^ permalink raw reply [flat|nested] 2+ messages in thread
* RE: Day Number
[not found] <616BE6A276E3714788D2AC35C40CD18D7404B9@whale.softwire.co.uk>
@ 2002-07-29 6:52 ` Rupert Wood
0 siblings, 0 replies; 2+ messages in thread
From: Rupert Wood @ 2002-07-29 6:52 UTC (permalink / raw)
To: dbisnath; +Cc: gcc-help
dbisnath wrote:
> How does one get the day number e.g. Sunday = 0, Monday = 1 etc ?
1. Use the time() function to get the system time value
2. Use localtime() or gmtime() to parse the time value into a tm struct
3. Read the tm_wday member from the structure.
e.g.
#include <stdio.h>
#include <time.h>
int main(void)
{
time_t t;
struct tm* tmLocal;
time(&t);
tmLocal = localtime(&t);
if (tmLocal != NULL)
{
printf("It's day number %d (0=Sunday, etc.)\n",
tmLocal->tm_wday);
}
else
{
printf("Error computing day number.\n");
return 1;
}
return 0;
}
You can get further information on these functions from the manual
pages, i.e. type 'man localtime'.
Rup.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-07-29 13:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-29 5:40 Day Number dbisnath
[not found] <616BE6A276E3714788D2AC35C40CD18D7404B9@whale.softwire.co.uk>
2002-07-29 6:52 ` Rupert Wood
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).