Replace functions next_instant & previous_instant with (more powerfull) offset_instant. New function "offset" for periods.