js: ensure date is correct length