return datetime.timedelta(seconds=seconds)


class TestReconstruction(unittest.TestCase):

    def test_reconstruct_timedelta_is_inverse_of_str(self):
        td = datetime.timedelta(weeks=300, days=20, hours=3, minutes=4,
            milliseconds=254, microseconds=984)
td_reconstructed = reconstruct_timedelta(str(td))
self.assertTrue(td == td_reconstructed)
if __name__ == '__main__':
    unittest.main()
How to convert a timedelta to a string and back again