Wouldn't you want `(t[unit] || 1);` instead?  That would default to milliseconds if the unit type didn't exist (or wasnt found) instead of zeroing out the whole duration.