Python pytz.timezone() Examples

The following are 30 code examples for showing how to use pytz.timezone(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module pytz , or try the search function .

Example 1
Project: wechatpy   Author: wechatpy   File: utils.py    License: MIT License 6 votes vote down vote up
def timezone(zone):
    """Try to get timezone using pytz or python-dateutil

    :param zone: timezone str
    :return: timezone tzinfo or None
    """
    try:
        import pytz

        return pytz.timezone(zone)
    except ImportError:
        pass
    try:
        from dateutil.tz import gettz

        return gettz(zone)
    except ImportError:
        return None 
Example 2
Project: InsightAgent   Author: insightfinder   File: getmetrics_cadvisor.py    License: Apache License 2.0 6 votes vote down vote up
def strip_tz_info(timestamp_format):
    # strptime() doesn't allow timezone info
    if '%Z' in timestamp_format:
        position = timestamp_format.index('%Z')
        strip_tz_fmt = PCT_Z_FMT
    if '%z' in timestamp_format:
        position = timestamp_format.index('%z')
        strip_tz_fmt = PCT_z_FMT
    
    if len(timestamp_format) > (position + 2):
        timestamp_format = timestamp_format[:position] + timestamp_format[position+2:]
    else:
        timestamp_format = timestamp_format[:position]
    if cli_config_vars['time_zone'] == pytz.timezone('UTC'):
        logger.warning('Time zone info will be stripped from timestamps, but no time zone info was supplied in the config. Assuming UTC')
    
    return {'strip_tz': True, 'strip_tz_fmt': strip_tz_fmt, 'timestamp_format': timestamp_format} 
Example 3
Project: InsightAgent   Author: insightfinder   File: getlogs_k8s.py    License: Apache License 2.0 6 votes vote down vote up
def strip_tz_info(timestamp_format):
    # strptime() doesn't allow timezone info
    if '%Z' in timestamp_format:
        position = timestamp_format.index('%Z')
        strip_tz_fmt = PCT_Z_FMT
    if '%z' in timestamp_format:
        position = timestamp_format.index('%z')
        strip_tz_fmt = PCT_z_FMT
    
    if len(timestamp_format) > (position + 2):
        timestamp_format = timestamp_format[:position] + timestamp_format[position+2:]
    else:
        timestamp_format = timestamp_format[:position]
    if cli_config_vars['time_zone'] == pytz.timezone('UTC'):
        logger.warning('Time zone info will be stripped from timestamps, but no time zone info was supplied in the config. Assuming UTC')
    
    return {'strip_tz': True, 'strip_tz_fmt': strip_tz_fmt, 'timestamp_format': timestamp_format} 
Example 4
Project: InsightAgent   Author: insightfinder   File: getlogs_evtx.py    License: Apache License 2.0 6 votes vote down vote up
def strip_tz_info(timestamp_format):
    # strptime() doesn't allow timezone info
    if '%Z' in timestamp_format:
        position = timestamp_format.index('%Z')
        strip_tz_fmt = PCT_Z_FMT
    if '%z' in timestamp_format:
        position = timestamp_format.index('%z')
        strip_tz_fmt = PCT_z_FMT
    
    if len(timestamp_format) > (position + 2):
        timestamp_format = timestamp_format[:position] + timestamp_format[position+2:]
    else:
        timestamp_format = timestamp_format[:position]
    if cli_config_vars['time_zone'] == pytz.timezone('UTC'):
        logger.warning('Time zone info will be stripped from timestamps, but no time zone info was supplied in the config. Assuming UTC')
    
    return {'strip_tz': True, 'strip_tz_fmt': strip_tz_fmt, 'timestamp_format': timestamp_format} 
Example 5
Project: InsightAgent   Author: insightfinder   File: getlogs_servicenow.py    License: Apache License 2.0 6 votes vote down vote up
def strip_tz_info(timestamp_format):
    # strptime() doesn't allow timezone info
    if '%Z' in timestamp_format:
        position = timestamp_format.index('%Z')
        strip_tz_fmt = PCT_Z_FMT
    if '%z' in timestamp_format:
        position = timestamp_format.index('%z')
        strip_tz_fmt = PCT_z_FMT

    if len(timestamp_format) > (position + 2):
        timestamp_format = timestamp_format[:position] + timestamp_format[position+2:]
    else:
        timestamp_format = timestamp_format[:position]

    return {'strip_tz': True,
            'strip_tz_fmt': strip_tz_fmt,
            'timestamp_format': [timestamp_format]} 
Example 6
Project: InsightAgent   Author: insightfinder   File: getmessages_elasticsearch2.py    License: Apache License 2.0 6 votes vote down vote up
def strip_tz_info(timestamp_format):
    # strptime() doesn't allow timezone info
    if '%Z' in timestamp_format:
        position = timestamp_format.index('%Z')
        strip_tz_fmt = PCT_Z_FMT
    if '%z' in timestamp_format:
        position = timestamp_format.index('%z')
        strip_tz_fmt = PCT_z_FMT

    if len(timestamp_format) > (position + 2):
        timestamp_format = timestamp_format[:position] + timestamp_format[position+2:]
    else:
        timestamp_format = timestamp_format[:position]
    if cli_config_vars['time_zone'] == pytz.timezone('UTC'):
        logger.warning('Time zone info will be stripped from timestamps, but no time zone info was supplied in the config. Assuming UTC')

    return {'strip_tz': True,
            'strip_tz_fmt': strip_tz_fmt,
            'timestamp_format': [timestamp_format]} 
Example 7
Project: InsightAgent   Author: insightfinder   File: getmessages_file_replay.py    License: Apache License 2.0 6 votes vote down vote up
def strip_tz_info(timestamp_format):
    # strptime() doesn't allow timezone info
    if '%Z' in timestamp_format:
        position = timestamp_format.index('%Z')
        strip_tz_fmt = PCT_Z_FMT
    if '%z' in timestamp_format:
        position = timestamp_format.index('%z')
        strip_tz_fmt = PCT_z_FMT

    if len(timestamp_format) > (position + 2):
        timestamp_format = timestamp_format[:position] + timestamp_format[position+2:]
    else:
        timestamp_format = timestamp_format[:position]

    return {'strip_tz': True,
            'strip_tz_fmt': strip_tz_fmt,
            'timestamp_format': [timestamp_format]} 
Example 8
Project: InsightAgent   Author: insightfinder   File: getlogs_tcpdump.py    License: Apache License 2.0 6 votes vote down vote up
def strip_tz_info(timestamp_format):
    # strptime() doesn't allow timezone info
    if '%Z' in timestamp_format:
        position = timestamp_format.index('%Z')
        strip_tz_fmt = PCT_Z_FMT
    if '%z' in timestamp_format:
        position = timestamp_format.index('%z')
        strip_tz_fmt = PCT_z_FMT

    if len(timestamp_format) > (position + 2):
        timestamp_format = timestamp_format[:position] + timestamp_format[position+2:]
    else:
        timestamp_format = timestamp_format[:position]
    if cli_config_vars['time_zone'] == pytz.timezone('UTC'):
        logger.warning('Time zone info will be stripped from timestamps, but no time zone info was supplied in the config. Assuming UTC')

    return {'strip_tz': True,
            'strip_tz_fmt': strip_tz_fmt,
            'timestamp_format': [timestamp_format]} 
Example 9
Project: InsightAgent   Author: insightfinder   File: getmetrics_sar.py    License: Apache License 2.0 6 votes vote down vote up
def strip_tz_info(timestamp_format):
    # strptime() doesn't allow timezone info
    if '%Z' in timestamp_format:
        position = timestamp_format.index('%Z')
        strip_tz_fmt = PCT_Z_FMT
    if '%z' in timestamp_format:
        position = timestamp_format.index('%z')
        strip_tz_fmt = PCT_z_FMT

    if len(timestamp_format) > (position + 2):
        timestamp_format = timestamp_format[:position] + timestamp_format[position+2:]
    else:
        timestamp_format = timestamp_format[:position]
    if cli_config_vars['time_zone'] == pytz.timezone('UTC'):
        logger.warning('Time zone info will be stripped from timestamps, but no time zone info was supplied in the config. Assuming UTC')

    return {'strip_tz': True, 'strip_tz_fmt': strip_tz_fmt, 'timestamp_format': timestamp_format} 
Example 10
Project: InsightAgent   Author: insightfinder   File: getmessages_prometheus.py    License: Apache License 2.0 6 votes vote down vote up
def strip_tz_info(timestamp_format):
    # strptime() doesn't allow timezone info
    if '%Z' in timestamp_format:
        position = timestamp_format.index('%Z')
        strip_tz_fmt = PCT_Z_FMT
    if '%z' in timestamp_format:
        position = timestamp_format.index('%z')
        strip_tz_fmt = PCT_z_FMT
    
    if len(timestamp_format) > (position + 2):
        timestamp_format = timestamp_format[:position] + timestamp_format[position+2:]
    else:
        timestamp_format = timestamp_format[:position]
    if cli_config_vars['time_zone'] == pytz.timezone('UTC'):
        logger.warning('Time zone info will be stripped from timestamps, but no time zone info was supplied in the config. Assuming UTC')
    
    return {'strip_tz': True, 'strip_tz_fmt': strip_tz_fmt, 'timestamp_format': timestamp_format} 
Example 11
Project: aws-ops-automator   Author: awslabs   File: time_service.py    License: Apache License 2.0 6 votes vote down vote up
def describe(self, as_tuple=None, **kwargs):
        """
        This method is to retrieve a pseudo UTC time resource, method parameters are only used signature compatibility
        :param as_tuple: Set to true to return results as immutable named dictionaries instead of dictionaries
        :return: Pseudo time resource
        """

        def use_tuple():
            return (as_tuple is not None and as_tuple) or (as_tuple is None and self._as_tuple)

        region = kwargs.get("region")
        result = {
            "Time": datetime.datetime.now(pytz.timezone("UTC")),
            "AwsAccount": self.aws_account,
            "Region": region if region else services.get_session().region_name
        }

        return [as_namedtuple("Time", result)] if use_tuple() else [result] 
Example 12
Project: aws-ops-automator   Author: awslabs   File: schedule_handler.py    License: Apache License 2.0 6 votes vote down vote up
def _get_last_run(self):
        """
        Returns the last UTC datetime this ops automator handler was executed.
        :return: Last datetime this handler was executed in timezone UTC
        """
        # get from table
        resp = self._last_run_table.get_item_with_retries(
            Key={
                NAME_ATTR: LAST_SCHEDULER_RUN_KEY
            }, ConsistentRead=True)

        # test if item was in table
        if "Item" in resp:
            return dateutil.parser.parse(resp["Item"]["value"]).replace(second=0, microsecond=0)
        else:
            # default for first call is current datetime minus one minute
            return datetime.now(tz=pytz.timezone("UCT")).replace(second=0, microsecond=0) - timedelta(minutes=1) 
Example 13
Project: pydfs-lineup-optimizer   Author: DimaKudosh   File: importer.py    License: MIT License 6 votes vote down vote up
def _parse_game_info(self, row: Dict) -> Optional[GameInfo]:
        game_info = row.get('Game Info')
        if not game_info:
            return None
        if game_info in ('In Progress', 'Final'):
            return GameInfo(  # No game info provided, just mark game as started
                home_team='',
                away_team='',
                starts_at='',
                game_started=True)
        try:
            teams, date, time, tz = game_info.rsplit(' ', 3)
            away_team, home_team = teams.split('@')
            starts_at = datetime.strptime(date + time, '%m/%d/%Y%I:%M%p').\
                replace(tzinfo=timezone(get_timezone()))
            return GameInfo(
                home_team=home_team,
                away_team=away_team,
                starts_at=starts_at,
                game_started=False
            )
        except ValueError:
            return None 
Example 14
Project: pydfs-lineup-optimizer   Author: DimaKudosh   File: test_late_swap.py    License: MIT License 6 votes vote down vote up
def setUp(self):
        self.future_game_info = GameInfo(home_team='H', away_team='A', game_started=False,
                                         starts_at=datetime.now(timezone('EST')) + timedelta(days=1))
        self.finished_game_info = GameInfo(home_team='H', away_team='A', game_started=False,
                                           starts_at=datetime.now(timezone('EST')) - timedelta(days=1))
        self.lineup_optimizer = get_optimizer(Site.DRAFTKINGS, Sport.BASKETBALL)
        positions = ['PG', 'SG', 'SF', 'PF', 'C', 'PG/SG', 'SF/PF', 'C']
        self.active_players = create_players(positions, game_info=self.future_game_info, salary=5000, fppg=20)
        self.inactive_players = create_players(positions, game_info=self.finished_game_info, salary=4500, fppg=10)
        self.lineup_optimizer.load_players(self.active_players + self.inactive_players)
        self.lineup = Lineup([
            LineupPlayer(self.active_players[0], 'PG'),
            LineupPlayer(self.inactive_players[1], 'SG'),
            LineupPlayer(self.active_players[2], 'SF'),
            LineupPlayer(self.inactive_players[3], 'PF'),
            LineupPlayer(self.active_players[4], 'C'),
            LineupPlayer(self.inactive_players[5], 'G'),
            LineupPlayer(self.active_players[6], 'F'),
            LineupPlayer(self.inactive_players[7], 'UTIL'),
        ]) 
Example 15
Project: donation-tracker   Author: GamesDoneQuick   File: test_event.py    License: Apache License 2.0 6 votes vote down vote up
def test_event_run_report(self):
        runs = randgen.generate_runs(self.rand, self.event, 2, scheduled=True)
        randgen.generate_runs(self.rand, self.event, 2, scheduled=False)
        runs[0].runners.add(*randgen.generate_runners(self.rand, 2))
        runs[1].runners.add(*randgen.generate_runners(self.rand, 1))
        resp = self.client.post(
            reverse('admin:tracker_event_changelist'),
            {'action': 'run_report', '_selected_action': [self.event.id]},
        )
        self.assertEqual(resp.status_code, 200)
        lines = [line for line in csv.reader(io.StringIO(resp.content.decode('utf-8')))]
        self.assertEqual(len(lines), 3)

        def line_for(run):
            return [
                str(run),
                run.event.short,
                run.starttime.astimezone(run.event.timezone).isoformat(),
                run.endtime.astimezone(run.event.timezone).isoformat(),
                ','.join(str(r) for r in run.runners.all()),
                ','.join(r.twitter for r in run.runners.all() if r.twitter),
            ]

        self.assertEqual(lines[1], line_for(runs[0]))
        self.assertEqual(lines[2], line_for(runs[1])) 
Example 16
Project: donation-tracker   Author: GamesDoneQuick   File: test_speedrun.py    License: Apache License 2.0 6 votes vote down vote up
def setUp(self):
        self.factory = RequestFactory()
        self.sessions = SessionMiddleware()
        self.messages = MessageMiddleware()
        self.event1 = models.Event.objects.create(
            datetime=today_noon,
            targetamount=5,
            timezone=pytz.timezone(getattr(settings, 'TIME_ZONE', 'America/Denver')),
        )
        self.run1 = models.SpeedRun.objects.create(
            name='Test Run 1', run_time='0:45:00', setup_time='0:05:00', order=1
        )
        self.run2 = models.SpeedRun.objects.create(
            name='Test Run 2', run_time='0:15:00', setup_time='0:05:00', order=2
        )
        if not User.objects.filter(username='admin').exists():
            User.objects.create_superuser('admin', 'nobody@example.com', 'password') 
Example 17
Project: snowflake-connector-python   Author: snowflakedb   File: test_daylight_savings.py    License: Apache License 2.0 6 votes vote down vote up
def _insert_timestamp(ctx, table, tz, dt):
    myzone = pytz.timezone(tz)
    ts = myzone.localize(dt, is_dst=True)
    print("\n")
    print('{}'.format(repr(ts)))
    ctx.cursor().execute("INSERT INTO {table} VALUES(%s)".format(
        table=table,
    ), (ts,))

    result = ctx.cursor().execute("SELECT * FROM {table}".format(
        table=table)).fetchone()
    retrieved_ts = result[0]
    print("#####")
    print('Retrieved ts: {}'.format(
        repr(retrieved_ts)))
    print('Retrieved and converted TS{}'.format(
        repr(retrieved_ts.astimezone(myzone))))
    print("#####")
    assert result[0] == ts
    ctx.cursor().execute("DELETE FROM {table}".format(
        table=table)) 
Example 18
Project: snowflake-connector-python   Author: snowflakedb   File: converter.py    License: Apache License 2.0 6 votes vote down vote up
def _TIMESTAMP_TZ_to_python(self, ctx):
        """Converts TIMESTAMP TZ to datetime.

        The timezone offset is piggybacked.
        """
        scale = ctx['scale']

        def conv0(encoded_value: str) -> datetime:
            value, tz = encoded_value.split()
            tzinfo = _generate_tzinfo_from_tzoffset(int(tz) - 1440)
            return datetime.fromtimestamp(float(value), tz=tzinfo)

        def conv(encoded_value: str) -> datetime:
            value, tz = encoded_value.split()
            microseconds = float(value[0:-scale + 6])
            tzinfo = _generate_tzinfo_from_tzoffset(int(tz) - 1440)
            return datetime.fromtimestamp(microseconds, tz=tzinfo)

        return conv if scale > 6 else conv0 
Example 19
Project: everyclass-server   Author: everyclass   File: ics_generator.py    License: Mozilla Public License 2.0 5 votes vote down vote up
def _get_datetime(week: int, day: int, time: Tuple[int, int], semester: Tuple[int, int, int]) -> datetime:
    """
    根据学期、周次、时间,生成 `datetime` 类型的时间

    :param week: 周次
    :param day: 星期
    :param time: 时间tuple(时,分)
    :param semester: 学期
    :return: datetime 类型的时间
    """
    config = get_config()
    tz = pytz.timezone("Asia/Shanghai")
    dt = datetime(*(config.AVAILABLE_SEMESTERS[semester]['start'] + time), tzinfo=tz)  # noqa: T484
    dt += timedelta(days=(week - 1) * 7 + day)  # 调整到当前周

    if 'adjustments' in config.AVAILABLE_SEMESTERS[semester]:
        ymd = (dt.year, dt.month, dt.day)
        adjustments = config.AVAILABLE_SEMESTERS[semester]['adjustments']
        if ymd in adjustments:
            if adjustments[ymd]['to']:
                # 调课
                dt = dt.replace(year=adjustments[ymd]['to'][0],
                                month=adjustments[ymd]['to'][1],
                                day=adjustments[ymd]['to'][2])
            else:
                # 冲掉的课年份设置为1984,返回之后被抹去
                dt = dt.replace(year=1984)

    return dt 
Example 20
Project: Servo   Author: fpsw   File: middleware.py    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
def process_request(self, request):
        tzname = request.session.get('django_timezone')
        if tzname:
            timezone.activate(pytz.timezone(tzname))
        else:
            timezone.deactivate() 
Example 21
Project: InsightAgent   Author: insightfinder   File: getlogs_servicenow.py    License: Apache License 2.0 5 votes vote down vote up
def get_timestamp_from_datetime(timestamp_datetime):
    # add tzinfo
    timestamp_localize = agent_config_vars['timezone'].localize(timestamp_datetime)

    # calc seconds since Unix Epoch 0
    epoch = long((timestamp_localize - datetime(1970, 1, 1, tzinfo=agent_config_vars['timezone'])).total_seconds()) * 1000
    return epoch 
Example 22
Project: InsightAgent   Author: insightfinder   File: getlogs_Pufa.py    License: Apache License 2.0 5 votes vote down vote up
def get_timestamp_for_zone(date_string, time_zone, datetime_format):
    dtexif = datetime.strptime(date_string, datetime_format)
    tz = pytz.timezone(time_zone)
    tztime = tz.localize(dtexif)
    epoch = long((tztime - datetime(1970, 1, 1, tzinfo=pytz.utc)).total_seconds()) * 1000
    return epoch 
Example 23
Project: InsightAgent   Author: insightfinder   File: getmessages_file_replay.py    License: Apache License 2.0 5 votes vote down vote up
def get_timestamp_from_datetime(timestamp_datetime):
    timestamp_localize = agent_config_vars['timezone'].localize(timestamp_datetime)

    epoch = long((timestamp_localize - datetime(1970, 1, 1, tzinfo=pytz.utc)).total_seconds()) * 1000
    return epoch 
Example 24
Project: InsightAgent   Author: insightfinder   File: getlogs_mysql.py    License: Apache License 2.0 5 votes vote down vote up
def get_gmt_timestamp(date_string, datetime_format):
    if datetime_format == Constant.NONE:
        return long(date_string)
    struct_time = datetime.strptime(date_string, datetime_format)
    time_by_zone = pytz.timezone(Constant.GMT).localize(struct_time)
    epoch = long((time_by_zone - datetime(1970, 1, 1, tzinfo=pytz.utc)).total_seconds()) * 1000
    return epoch 
Example 25
Project: InsightAgent   Author: insightfinder   File: get_logs_mssql.py    License: Apache License 2.0 5 votes vote down vote up
def get_gmt_timestamp(date_string, datetime_format):
    if datetime_format == Constant.NONE:
        return long(date_string)
    struct_time = datetime.strptime(date_string, datetime_format)
    time_by_zone = pytz.timezone(Constant.GMT).localize(struct_time)
    epoch = long((time_by_zone - datetime(1970, 1, 1, tzinfo=pytz.utc)).total_seconds()) * 1000
    return epoch 
Example 26
Project: aws-ops-automator   Author: awslabs   File: cron_expression.py    License: Apache License 2.0 5 votes vote down vote up
def _localized_time(self, dt=None):
        """
        Checks if timezone information must be added to tz. If the dt parameter is not set then the default dt set in the parameter
        if used if it was set otherwise the  localized current time is used
        :param dt: Tested datetime or None for current datetime
        :return: Localized datetime
        """
        if dt:
            return dt.replace(tzinfo=self._timezone) if dt.tzinfo is None else dt
        return datetime.now(tz=self._timezone) 
Example 27
Project: aws-ops-automator   Author: awslabs   File: __init__.py    License: Apache License 2.0 5 votes vote down vote up
def build_str_from_template(tags_str, task, task_id, timezone="UTC", account=None, region=None, tag_variables=None):
    return build_tags_from_template("str=" + tags_str, task, task_id,
                                    timezone=timezone,
                                    account=account, region=region,
                                    tag_variables=tag_variables)["str"] 
Example 28
Project: aws-ops-automator   Author: awslabs   File: task_admin_api.py    License: Apache License 2.0 5 votes vote down vote up
def _get_next_task_execution(name, context=None, logger=None, days=None, hours=None, minutes=None, include_disabled=False):
    def get_period():
        period = 0
        if days is not None:
            period += days * 60 * 24
        if hours is not None:
            period += 60 * hours
        if minutes is not None:
            period += minutes

        return timedelta(minutes=period if period != 0 else 24 * 60)

    result = {"Name": name}

    task = _get_task(name, context=context, logger=logger)

    enabled = task[configuration.CONFIG_ENABLED]
    result["Enabled"] = enabled

    if not enabled and include_disabled:
        return safe_json(result)

    task_interval = task.get(configuration.CONFIG_INTERVAL, None)
    result["Interval"] = task_interval
    if task_interval is None:
        return safe_json(result)

    task_cron_expression = CronExpression(expression=task_interval)
    task_timezone = task.get(configuration.CONFIG_TIMEZONE, "UTC")
    result["Timezone"] = task_timezone

    now = datetime.now(tz=pytz.timezone(task_timezone))
    next_execution = task_cron_expression.first_within_next(get_period(), now)
    if next_execution is None:
        return safe_json(result)

    result["NextExecution"] = next_execution

    return result 
Example 29
Project: aws-ops-automator   Author: awslabs   File: schedule_handler.py    License: Apache License 2.0 5 votes vote down vote up
def _set_last_run(self):
        """
        Stores and returns the current datetime in UTC as the last execution time of this handler.
        :return: Stored last execution time in UTC timezone
        """
        dt = datetime.now(tz=pytz.timezone("UCT")).replace(second=0, microsecond=0)
        self._last_run_table.update_item(
            Key={NAME_ATTR: LAST_SCHEDULER_RUN_KEY},
            AttributeUpdates={
                "value": {"Action": "PUT", "Value": dt.isoformat()}
            })
        return dt 
Example 30
Project: aws-ops-automator   Author: awslabs   File: schedule_handler.py    License: Apache License 2.0 5 votes vote down vote up
def _set_next_schedule_event(self, scheduler_dt, next_executed_task):
        """
        Sets the cron expression of the scheduler event rule in cloudwatch depending on next executed task
        :param scheduler_dt: dt used for this scheduler run
        :param next_executed_task: Next task to execute
        :return:
        """
        if next_executed_task is not None:

            utc = pytz.timezone("UTC")

            time_str = "{} ({})".format(next_executed_task[0].isoformat(), utc)
            next_task_tz = pytz.timezone(next_executed_task[1][handlers.TASK_TIMEZONE])
            if next_task_tz != utc:
                time_str += ", {} ({})".format(next_executed_task[0].astimezone(next_task_tz), next_task_tz)
            self._logger.info(INFO_NEXT_EXECUTED_TASK, next_executed_task[1][handlers.TASK_NAME], time_str)

            if next_executed_task[0] > scheduler_dt + timedelta(minutes=5):
                next_event_time = handlers.set_event_for_time(next_executed_task[0], task=next_executed_task[1],
                                                              logger=self._logger, context=self._context)
                self._logger.info(INF_NEXT_EVENT, next_event_time.isoformat())
            else:
                handlers.set_scheduler_rule_every_minute(task=next_executed_task[1])
                self._logger.info(INFO_NEXT_ONE_MINUTE)
        else:
            self._logger.info(INFO_NO_TASKS_SCHEDULED)
            next_event_time = handlers.set_event_for_time(scheduler_dt, context=self._context, logger=self._logger)
            self._logger.info(INF_NEXT_EVENT, next_event_time.isoformat())