OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # -*- coding: utf-8 -*- | 2 # -*- coding: utf-8 -*- |
3 """This file contains a unit test for the timelib in Plaso.""" | 3 """This file contains a unit test for the timelib in Plaso.""" |
4 | 4 |
5 from __future__ import unicode_literals | 5 from __future__ import unicode_literals |
6 | 6 |
7 import datetime | 7 import datetime |
8 import unittest | 8 import unittest |
9 | 9 |
10 from plaso.lib import errors | 10 from plaso.lib import errors |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 # Should be rounded up. | 329 # Should be rounded up. |
330 test_one = 442813351785412 | 330 test_one = 442813351785412 |
331 # Should be rounded down. | 331 # Should be rounded down. |
332 test_two = 1384381247271976 | 332 test_two = 1384381247271976 |
333 | 333 |
334 self.assertEqual( | 334 self.assertEqual( |
335 timelib.Timestamp.RoundToSeconds(test_one), 442813352000000) | 335 timelib.Timestamp.RoundToSeconds(test_one), 442813352000000) |
336 self.assertEqual( | 336 self.assertEqual( |
337 timelib.Timestamp.RoundToSeconds(test_two), 1384381247000000) | 337 timelib.Timestamp.RoundToSeconds(test_two), 1384381247000000) |
338 | 338 |
339 def testTimestampFromTimeParts(self): | |
340 """Test the FromTimeParts function.""" | |
341 timestamp = timelib.Timestamp.FromTimeParts( | |
342 2013, 6, 25, 22, 19, 46, 0, timezone=pytz.timezone('PST8PDT')) | |
343 expected_timestamp = timelib.Timestamp.CopyFromString( | |
344 '2013-06-25 22:19:46-07:00') | |
345 self.assertEqual(timestamp, expected_timestamp) | |
346 | |
347 expected_timestamp = timelib.Timestamp.CopyFromString( | |
348 '2013-06-26 05:19:46') | |
349 timestamp = timelib.Timestamp.FromTimeParts(2013, 6, 26, 5, 19, 46) | |
350 self.assertEqual(timestamp, expected_timestamp) | |
351 | |
352 expected_timestamp = timelib.Timestamp.CopyFromString( | |
353 '2013-06-26 05:19:46.000542') | |
354 timestamp = timelib.Timestamp.FromTimeParts( | |
355 2013, 6, 26, 5, 19, 46, microseconds=542) | |
356 self.assertEqual(timestamp, expected_timestamp) | |
357 | |
358 | 339 |
359 if __name__ == '__main__': | 340 if __name__ == '__main__': |
360 unittest.main() | 341 unittest.main() |
OLD | NEW |