Opened 15 years ago
Closed 15 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: |
Description
Need an easy way to add to date object. This uses same tokens as the toString function.
dojo.date.add = function(datePart, number, date) { var newDate = new Date(date.valueOf()); switch (datePart) { case "d" : newDate.setDate(newDate.getDate() + number); break; case "M" : newDate.setMonth(date.getMonth() + number); break; case "y" : newDate.setFullYear(date.getFullYear() + number); break; case "H": case "h": newDate.setHours(date.getHours() + number); break; case "m": newDate.setMinutes(date.getMinutes() + number); break; case "s": newDate.setSeconds(date.getSeconds() + number); break; } return newDate; }
Change History (2)
comment:1 Changed 15 years ago by
comment:2 Changed 15 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
I added this to date.js about 3 weeks ago (without seeing your bug post)...since dojo.date.toString was killed, there is an enum in date for this usage.
Note: See
TracTickets for help on using
tickets.
My cla is on file if you want to include this function.