When we need to extend the functionality of a business object behavior, there are two options. You could write the code yourself or you can use an external package. With Apex Designer being a Node.js application, the use of an NPM package makes logical sense and we have made it easy to do.
Adding the Dependency to the Behavior
Date Manipulation is a common need for an application. One of our favorite NPM packages to do that is day.js.
First, be sure that you have added the package to the project on the server side as described in Dependencies. Then in the behavior simply start typing its name in the Add dependency field and click the name to add it.
If you expand the dependency panel, you can see the alias used to reference it.
The to use it in your method, just reference it by alias
//monthDate is an input parameter of type date
var daysInMonth = dayjs(monthDate).daysInMonth()
return daysInMonth