BLITZ | Steven Sacks - 310-551-0200 x209
> -----Original Message----- > From: [EMAIL PROTECTED] [mailto:flashcoders- > [EMAIL PROTECTED] On Behalf Of Steven Sacks | BLITZ > Sent: Friday, July 28, 2006 12:22 PM > To: Flashcoders mailing list > Subject: [Flashcoders] Date Empowerment > > The next in my Empowerment series of scripts tackles the Date object. > Rails introduced a ton of great shortcuts and methods to their Time > object, the equivalent to the Date object in Flash (though much easier > to use). I've appropriated all their methods and added a few more. > There are some great methods in here that really save time when you need > to do things with the Date object. > > -------------------------------------------------------------- > > // XDate > // The following calculations are all relative to the current date > object > // not the current date - this is an important distinction > > // General function for easily altering the date object > // pass the option (a string) and how much you want to alter it > Date.prototype.change = function(option, amount) { > if (isNan(Number(amount))) return undefined; > var year = this.getFullYear(); > var time = this.getTime(); A quick fix to two methods that should have used "weeks" not "days" in their change methods. // Sets date representing the start of the given day in next week (default is Monday). Date.prototype.nextWeek = function(sunday) { this.change("weeks", 1); if (!sunday) { this.monday(); } else { this.sunday() } }; // Sets date representing the start of the given day in last week (default is Monday). Date.prototype.lastWeek = function(sunday) { this.change("weeks", -1); if (!sunday) { this.monday(); } else { this.sunday() } }; _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com