Hide navigation sidebar
Hide table of contents sidebar
Back to top
Toggle table of contents sidebar

# self.to_default_timezone

strategies.strategy.Strategy.to_default_timezone(self, dt: datetime)

  Returns a datetime localized to the data source’s default timezone.

  Parameters:

    dt (datetime.datetime) – The datetime to localize.

  Returns:

    The localized datetime.

  Return type:

    datetime.datetime

  Example

      >>> # Will return a datetime localized to the data source's default timezone
      >>> to_default_timezone = self.to_default_timezone(dt=datetime.datetime(2020, 1, 1))
      >>> self.log_message(f"Localized datetime: {to_default_timezone}")