Improve the getValue method to adjust dates as per the selected period