Change this to `if (typeof time === 'object' && typeof time.getTime === 'function')`