refactor(datepicker): Move logic into a controller

Move logic from datepicker LinkingFunction to controller so the behavior of the component can be easier to extend.