File: test_time.py

package info (click to toggle)
python-fs 2.4.16-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,944 kB
  • sloc: python: 13,048; makefile: 226; sh: 3
file content (23 lines) | stat: -rw-r--r-- 630 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from __future__ import print_function, unicode_literals

import unittest
from datetime import datetime

from fs.time import datetime_to_epoch, epoch_to_datetime

try:
    from datetime import timezone
except ImportError:
    from fs._tzcompat import timezone  # type: ignore


class TestEpoch(unittest.TestCase):
    def test_epoch_to_datetime(self):
        self.assertEqual(
            epoch_to_datetime(142214400), datetime(1974, 7, 5, tzinfo=timezone.utc)
        )

    def test_datetime_to_epoch(self):
        self.assertEqual(
            datetime_to_epoch(datetime(1974, 7, 5, tzinfo=timezone.utc)), 142214400
        )