Skip to content

Adding / Removing: days, month or Years to Date

May 21, 2010
private function addToDate(date:Date):Date {
   switch (period_cb.selectedLabel) {
     case "Day":
           var temp:Date = new Date(date.getFullYear(),date.getMonth(),date.getDate() + Number(valueDate_ti.text));
           break;
     case "Week":
           var temp:Date = new Date(date.getFullYear(),date.getMonth(),date.getDate() + Number(valueDate_ti.text) * 7);
           break;
     case "Month":
           var temp:Date = new Date(date.getFullYear(),date.getMonth() + Number(valueDate_ti.text),date.getDate());
           break;
     case "Year":
           var temp:Date = new Date(date.getFullYear() + Number(valueDate_ti.text),date.getMonth(),date.getDate());
           break;
   }
   return temp;
}

valueDate_ti is a text input that accept numbers to add to the date,
period_cb is a ComboBox, which selects the cycle time: Day, Week, Month, Year;

Advertisements

From → AIR, Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: