Opened 11 years ago

Closed 10 years ago

#8973 closed defect (fixed)

Strange results with invalid interval in dojo.date.add

Reported by: emj Owned by: Adam Peller
Priority: high Milestone: 1.4
Component: Date Version: 1.3.0b3
Keywords: Cc:
Blocked By: Blocking:

Description

If you supply dojo.date.add with an invalid interval, such as "seconds" instead of "second" it adds the amount in days.

Ex: dojo.date.add(new Date(), "seconds", 3600); would add almost ten years to the date instead of the expected hour.

A good solution would be to throw an exception or perhaps add a default no-op.

Change History (3)

comment:1 Changed 11 years ago by Adam Peller

Milestone: tbd1.4

We can make this an exception by adding

default: property="";

to the switch. It's incompatible, but only for improper uses of the API. Unfortunately, it's an easy mistake to make, and probably best to flag. The alternative is

default: return sum;

thoughts?

comment:2 in reply to:  1 Changed 11 years ago by emj

I believe that the Exception is the way to go since it isn't a valid parameter.

Replying to peller:

We can make this an exception by adding

default: property="";

to the switch. It's incompatible, but only for improper uses of the API. Unfortunately, it's an easy mistake to make, and probably best to flag. The alternative is

default: return sum;

thoughts?


comment:3 Changed 10 years ago by Adam Peller

Resolution: fixed
Status: newclosed

Fixed in [17270]

Note: See TracTickets for help on using tickets.