how many days in each month?

Reply

Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

how many days in each month?

 
0
  #1
Sep 20th, 2005
Anyone know how I can tell how many days are in each month? A formula would be really nice.
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,841
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 751
Team Colleague
Narue's Avatar
Narue Narue is online now Online
Senior Bitch

Re: how many days in each month?

 
0
  #2
Sep 20th, 2005
For non-leap years, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31. For leap years, add one to February using the formula:

((year MOD 4 = 0 AND year MOD 100 <> 0) OR year MOD 400 = 0)
New members chased away this month: 3
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: how many days in each month?

 
0
  #3
Sep 20th, 2005
Thanks! Now I just need to find some cool things to do with dates!
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,841
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 751
Team Colleague
Narue's Avatar
Narue Narue is online now Online
Senior Bitch

Re: how many days in each month?

 
0
  #4
Sep 21st, 2005
>Now I just need to find some cool things to do with dates!
How about a program that can unravel the mess?
New members chased away this month: 3
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: how many days in each month?

 
0
  #5
Sep 21st, 2005
I'm trying to do something that will help me learn a little. I know all the easy stuff but I can't find anything to do with pointers and references. I have add and subtract functions, but none of those require me to use references or points
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,841
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 751
Team Colleague
Narue's Avatar
Narue Narue is online now Online
Senior Bitch

Re: how many days in each month?

 
0
  #6
Sep 21st, 2005
Do you want to learn about time and date programming or about references and pointers? You would be better off playing with some high level data structures for the latter.
New members chased away this month: 3
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: how many days in each month?

 
0
  #7
Sep 21st, 2005
I don't really care about date/time programming, but I just wanted to start a program that could possibly give me some good experience. I'm most interested in getting more experience with pointers and references, so I thought I could implement something in the date class I was making, but was wrong.

See, the two functions I have return dates, because that seems to be the most sensible approach:

Date Date::add(Date addThis)
{
}

At first I was hoping for a function that used references or pointers, but it would turn out messy, and kind of stupid:

void Date::add(Date addThis, Date &ref)
{
}

The only way I could think of using references was to provide a second paramenter, which seems like a terrible solution.

I hope you see what I'm getting at even though I don't write very clear!
Anyways, I'm reading three different books and got more than enough experience with refs and pointers with in text reading, but I want hands on experience. I just can't seem to find something useful to do. I mean, almost everything I think can be done returning the object rather than using a reference.

Any of that make sense!
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,841
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 751
Team Colleague
Narue's Avatar
Narue Narue is online now Online
Senior Bitch

Re: how many days in each month?

 
0
  #8
Sep 21st, 2005
>I'm most interested in getting more experience with pointers and references
Write a balanced binary search tree. That will give you plenty of experience with pointers. See below for a recommendation to get a handle (pun intended) on references.

>which seems like a terrible solution.
Probably because it is.

>I mean, almost everything I think can be done returning the object rather than using a reference.
Create your own stream. You'll be forced to use references heavily.
New members chased away this month: 3
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: how many days in each month?

 
0
  #9
Sep 22nd, 2005
Thanks Narue!
I believe I'm going to try the binary search tree first. It won't be till this weekend, but look around for me in the ++ forum, just in case I have problems
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for IT Professionals' Lounge
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC