import pytz
from pytz import timezone


class TimeManager:
    timezone_object = None

    @staticmethod
    def init_timezone(timezone_str):
        TimeManager.timezone_object = timezone(timezone_str)

    @staticmethod
    def get_timezone():
        return TimeManager.timezone_object

    @staticmethod
    def localize(dt):
        utc_dt = pytz.utc.localize(dt)
        return utc_dt.astimezone(TimeManager.get_timezone())

@@ -1,19 +1,39 @@
 import 
-pytz
+datetime%0Aimport logging%0A
 %0Afrom py
@@ -53,16 +53,145 @@
 ezone%0A%0A%0A
+log = logging.getLogger(__name__)%0A%0A%0Adef is_naive_datetime(dt):%0A    return dt.tzinfo is None or dt.tzinfo.utcoffset(dt) is None%0A%0A%0A
 class Ti
@@ -484,38 +484,535 @@
     
-utc_dt = pytz.utc.localize(dt)
+%22%22%22Localizes the given datetime into the display timezone.%0A%0A        If the given datetime is naive, it is assumed to be of the UTC timezone.%0A        Non-naive datetimes will be directly converted to the target display timezone.%22%22%22%0A        if is_naive_datetime(dt):%0A            log.warning(%22Naive datetime passed to TimeManager#localize() %22%0A                        %22(Naive datetimes should not be used in the bot anymore)%22)%0A            input_dt = dt.replace(tzinfo=datetime.timezone.utc)%0A        else:%0A            input_dt = dt%0A
 %0A   
@@ -1023,19 +1023,21 @@
  return 
+inp
 ut
-c
 _dt.asti

Make TimeManager compatible with non-naive datetimes