Opened 16 years ago

Closed 16 years ago

#306 closed defect (fixed)

Dojo Needs a date.add function

Reported by: anonymous Owned by: anonymous
Priority: high Milestone:
Component: General Version: 0.2
Keywords: Cc:
Blocked By: Blocking:


Need an easy way to add to date object. This uses same tokens as the toString function. = function(datePart, number, date) {
	var newDate = new Date(date.valueOf());
	switch (datePart) {
		case "d" :
			newDate.setDate(newDate.getDate() + number);
		case "M" :
			newDate.setMonth(date.getMonth() + number);
		case "y" :
			newDate.setFullYear(date.getFullYear() + number);
		case "H":
		case "h":
			newDate.setHours(date.getHours() + number);
		case "m":
			newDate.setMinutes(date.getMinutes() + number);
		case "s":
			newDate.setSeconds(date.getSeconds() + number);
	return newDate;

Change History (2)

comment:1 Changed 16 years ago by Michael Schall

My cla is on file if you want to include this function.

comment:2 Changed 16 years ago by Tom Trenka

Resolution: fixed
Status: newclosed

I added this to date.js about 3 weeks ago (without seeing your bug post)...since was killed, there is an enum in date for this usage.

Note: See TracTickets for help on using tickets.