zona_waktu.py
707 Bytes
import unittest
import pytz
from datetime import (
date,
datetime,
)
from opensipkd.waktu import create_datetime
class ZonaWaktu(unittest.TestCase):
def setUp(self):
self.from_str = '2020-10-15 13:59:32,595'
def test_to_str(self):
without_tz = datetime.strptime(self.from_str, '%Y-%m-%d %H:%M:%S,%f')
with_tz = create_datetime(
without_tz.year, without_tz.month, without_tz.day,
without_tz.hour, without_tz.minute, without_tz.second,
without_tz.microsecond)
to_str = with_tz.strftime('%Y-%m-%d %H:%M:%S,%f')
to_str = to_str.rstrip('0')
self.assertEqual(self.from_str, to_str)