You can also check out the Date::Calc module at www.engelschall.com/u/sb/download/Date-Calc/ It simplifies a lot of date calculations including the number of days in the month, days 'till the end of the year, leap years, etc.
-----Original Message----- From: Darryl Schnell [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 29, 2002 9:34 AM To: [EMAIL PROTECTED] Subject: RE: Remain Days of Month & Leap Year Question Thank-You all regarding this matter. It works great. I should have been able to figure this one out on my own, guess I need to brush or relearn how to use the Time function. Thanks Again, -----Original Message----- From: Jason Purdy [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 29, 2002 12:02 PM To: McCollum, Frank; Darryl Schnell; [EMAIL PROTECTED] Subject: Re: Remain Days of Month & Leap Year Question Leap-year is a little more complicated than that (from http://www.ips.gov.au/papers/richard/leap.html): "A year is a leap year (and so contains a February 29) if it is divisible by 4. But if the year is also divisible by 100 then it is not a leap year, unless it is divisible by 400." A neater way to test if it's (or anything is) divisible by 4 is to use the modulus operator: if ( $year % 4 == 0 ) { # it is divisible by 4 } else { # it isn't } Jason If memory serves me right, on Tuesday 29 January 2002 11:52, McCollum, Frank wrote: > I've never done this, but it seems to me it would be nice to set up the > days per month in a little hash table. > > %calendarDays ( > january => 31, > february => 28, > .... > ) > #or should the order be reversed? I'm not that familiar with Hashes. > > Then have a check in there that grabs the date (see previous emails on > localtime to get date). if the year is divisible by 4, then the value for > Febrary would be 29 instead of 28. (there is probably a cleaner way, but > here is an untested idea..) > > $yearCheck = $year / 4; > if ( $yearCheck = int $yearCheck ) { $calendar{'february'} = 29 } > > $yearCheck divides the year by 4, and then checks to see if it is an > integer. If it is, then change February's days to 29. I did not test this, > and I am a newbie, so take it for what it is. > > -Frank > > -----Original Message----- > From: Darryl Schnell [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, January 29, 2002 11:24 AM > To: [EMAIL PROTECTED] > Subject: Remain Days of Month & Leap Year Question > > > Greeting's All, > > I am currently working on a prorate billing routine for an online form and > need a bit of guidance. The idea behind the program is to take 19.95 and > divde that by the total of remain days in the month, using the day of the > month the user filled out the form as the starting point. > > Getting the Day of Sign-Up and Calculating the cost I can handle, what I'm > not sure how to accomplish is how do I get the total of remaining days in > the month, how do I determine how many days that month has, and how do I > take into account Leap Years? > > I relaize that this should be a basically simple matter so if any one has > some documentation that I could read that might help me figure this out I > would appreciate a shove in that direction. I tried doing a search on the > web and found some Calculating Date information but was still left alittle > foggy. > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -------------------------------------------------------------------------------- This email may contain confidential and privileged material for the sole use of the intended recipient. If you are not the intended recipient, please contact the sender and delete all copies. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]