Side-note: I wonder if this is a little heavy for running on each timestamp in a loop -- formatting timestamps is in my experience pretty slow.