Opened 14 years ago

Closed 14 years ago

Last modified 12 years ago

#585 closed defect (fixed)

dojo.date.add (copy and paste typo bug)

Reported by: freshhawk@… Owned by: anonymous
Priority: high Milestone:
Component: Core Version: 0.2
Keywords: date time Cc:
Blocked By: Blocking:

Description

dojo.date.add function takes in n, units and will always add n years as well as n units to the date (example: you try to add 5 minutes and it adds 5 years and 5 minutes). Looks like it was a simple copy and paste bug but it makes all of the data coming out of that function wrong (sometimes subtly wrong).

Here's the diff of the fix but it's easy to spot by eye:

break;

} case dojo.date.dateParts.MONTH:{

  • v=new Date(d.getFullYear()+n, d.getMonth()+n, d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds());

+ v=new Date(d.getFullYear(), d.getMonth()+n, d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds());

break;

} case dojo.date.dateParts.HOUR:{

  • v=new Date(d.getFullYear()+n, d.getMonth(), d.getDate(), d.getHours()+n, d.getMinutes(), d.getSeconds(), d.getMilliseconds());

+ v=new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours()+n, d.getMinutes(), d.getSeconds(), d.getMilliseconds());

break;

} case dojo.date.dateParts.MINUTE:{

  • v=new Date(d.getFullYear()+n, d.getMonth(), d.getDate(), d.getHours(), d.getMinutes()+n, d.getSeconds(), d.getMilliseconds());

+ v=new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes()+n, d.getSeconds(), d.getMilliseconds());

break;

} case dojo.date.dateParts.SECOND:{

  • v=new Date(d.getFullYear()+n, d.getMonth(), d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds()+n, d.getMilliseconds());

+ v=new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds()+n, d.getMilliseconds());

break;

} case dojo.date.dateParts.MILLISECOND:{

  • v=new Date(d.getFullYear()+n, d.getMonth(), d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds()+n);

+ v=new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds()+n);

break;

} default:{

Sorry for the bad formatting.

Change History (3)

comment:1 Changed 14 years ago by Tom Trenka

Resolution: fixed
Status: newclosed

Thanks for the catch, fixed.

comment:2 Changed 14 years ago by bill

Milestone: 0.3release

comment:3 Changed 12 years ago by (none)

Milestone: 0.3release

Milestone 0.3release deleted

Note: See TracTickets for help on using tickets.