Contents
Articles
Behaviors
Books
Director News
Director Web Sites
FAQ
Games
Mailing Lists
News Groups
Project Examples
Reviews
Software
Tools
Useful Web Sites
Utilities
Xtras

Don't miss these
3D games online. New cosmic world of Tensoric.
Quiz engine
SkyDir
Flash Movie Controls
Milliseconds
bubbleSortForStrings AND bubbleSortForStringLists
3DVista Studio Director Xtra
PrintOMatic
PDF Xtra-L
cXtraTransitionMorphing
 

 

 

Behavior Number of Days in a Month

Added on 12/12/2005

 

Compatibilities:
D8 D8_5 D9 PC Script

This item has not yet been rated

Author: Chunick (website)

This should be placed in a moviescript. To use place script in a movieScript and call from anywhere, such as the message window. You can either pass the month and year or just the month... which will assume the current year. One big thing to note is that the code is much more than you would normally need to do the job. Here's the code you would normally need: on daysInMonth(theMonth, theYear) return date(theYear, theMonth + 1, 1) - date(theYear, theMonth, 1) end However, this is a bit inflexible... let's say I don't want to provide the year or maybe I want to provide the name of the month rather than the month number... or even the abbreviated name of the month... all of that is possible with the first custom handler. All that being said, here are some of the parameters that can be passed: -- from the message window if the code is placed in a moviescript put daysInMonth(12, 2005) -- 31 put daysInMonth(11) -- 30 put daysInMonth("February") -- 28 put daysInMonth("feb") -- 28 put daysInMonth("Feb") -- 28 Actually, this behavior is a good example of how to use the findPosNear() function for lists as well as allowing for different data types and numbers of parameters to be passed to a function.

on daysInMonth(theMonth, theYear)
months = [#January: 1, #February: 2, #March: 3, #April: 4, #May: 5, #June: 6, #July: 7, #August: 8, #September: 9, #October: 10, #November: 11, #December: 12]
months.sort()
if ilk(theMonth) = #string then theMonth = months[months.findPosNear(symbol(theMonth))]
if theYear = 0 then theYear = the systemDate.year
return date(theYear, theMonth + 1, 1) - date(theYear, theMonth, 1)
end

 


Contact

MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA

Send e-mail