Created
April 1, 2017 20:52
-
-
Save edgabaldi/7265ccea8f455fbcc0d3e56843ce33a4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from unittest import TestCase | |
import datetime | |
def d2t(t): | |
h = int(t) | |
m = (t * 60) % 60 | |
s = (t * 3600) % 60 | |
a = map(lambda x: int(x), [h, m, s]) | |
return datetime.time(*a) | |
class D2TTestCase(TestCase): | |
def test_d2t(self): | |
self.assertEqual(datetime.time(1,0), d2t(1.0)) | |
self.assertEqual(datetime.time(23, 27), d2t(23.450)) | |
if __name__ == "__main__": | |
unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment