Added method to calculate next matching timestamp