Fix history timespans logic

Bug: 61244
Change-Id: Idb7c932a2a21b128b595faf9aff41f4b3a73d989