|
1. Day of the Week Function
|
|
Tue Oct 2, 2007 [2:26 PM]
|
807
robby_burney@yahoo.com
member since: Mar 16, 2005
|
Reply
|
|
Allo there. I am trying to setup random occurrences for different days of the week (Monday gets X bonus, Tuesday gets Y detriment, Wednesday get Z event, etc), but I'm having trouble setting up the declarations. So basically, this might be really simple, or it might be really hard depending on how we think about this. Here's the equation I found that seems perfect for this operation:
int dayofweek(int d, int m, int y) { return (d+=m<3?y--:y-2,23*m/9+d+4+y/4-y/100+y/400)%7; }
Now, I'm running a ROM/Rot off a UNIX system and the mud is coded in C. I don't know of a way to tell the mud "IS_MONDAY" or to break down the server/system time to plug it into that equation. So either I need help figuring out how to tell the mud what day of the week it is, or I need help figuring out how to utilize this input-the-date equation to give me the information.
Robby
|
|
|
|
|
2. RE: Day of the Week Function
|
|
Tue Oct 2, 2007 [3:24 PM]
|
Jindrak
Email not supplied
member since: Jun 9, 2002
|
In Reply To
Reply
|
|
man -a mktime
You're trying to create a function you don't need to.
struct tm time = *localtime( ¤t_time );
From there you can point to 'tm_wday'.
|
|
|
|
|
3. RE: Day of the Week Function
|
|
Tue Oct 2, 2007 [5:49 PM]
|
807
Email not supplied
member since: Mar 16, 2005
|
In Reply To
Reply
|
|
Thanks man. I am not a coding newbie (well, that sounds a little funny all things considered) but lets just say I hate the time system in UNIX... Thank you again,
Robby
|
|
|
|
|
4. RE: Day of the Week Function
|
|
Wed Oct 3, 2007 [8:08 AM]
|
sandog
Email not supplied
member since: Jan 20, 2002
|
In Reply To
Reply
|
I hate the time system in UNIX
Not sure what other system you programmed on, but in MSDOS world the same structure exists as well as the same function, mktime. At least in the world of the MSDOS C-Runtime library (which includes C++ as well, I believe). Since C existed on Unix before MSDOS I would say that MSDOS ripped it off, but, as they say, imitation is the truest form of flattery =).
|
|
|
I know what your thinking, "Why didn't I take the blue pill?". - Cypher, The Matrix
|
|