Add a month to selectable date range – Date Chooser – Actionscript 2

0 min read 108 words

I have been working on a project where I need to select a date range starting today and ending a month from now, so the user cannot select anything in the past or over a month from now.

This is how I did it:

There is an instance of DateChooser on the stage with Instance Name “calDate”.

var todayDate:Date = new Date();
dateBeginDay = todayDate.getDate();
dateBeginMonth = todayDate.getMonth();
dateBeginYear = todayDate.getFullYear();

if ((todayDate.getMonth()+1)==12) {
  dateEndDay = todayDate.getDate();
  dateEndMonth = 1;
  dateEndYear = todayDate.getFullYear()+1;
} else {
  dateEndDay = todayDate.getDate();
  dateEndMonth = todayDate.getMonth()+1;
  dateEndYear = todayDate.getFullYear();
}
calDate.selectableRange = {rangeStart: new Date(dateBeginYear, dateBeginMonth, dateBeginDay), rangeEnd: new Date(dateEndYear, dateEndMonth, dateEndDay)}
Andrew
Andrew

Andrew is a visionary software engineer and DevOps expert with a proven track record of delivering cutting-edge solutions that drive innovation at Ataiva.com. As a leader on numerous high-profile projects, Andrew brings his exceptional technical expertise and collaborative leadership skills to the table, fostering a culture of agility and excellence within the team. With a passion for architecting scalable systems, automating workflows, and empowering teams, Andrew is a sought-after authority in the field of software development and DevOps.

Tags