Skip to content

Bug: SCHEDULE_BETWEEN_DAYS_OF_WEEK stops matching when LC_TIME is not English #8706

Open

Description

@anishmehta24

Expected Behaviour

A SCHEDULE_BETWEEN_DAYS_OF_WEEK rule with "DAYS": ["FRIDAY"] matches on Fridays whatever locale the function runs with.

Current Behaviour

compare_days_of_week gets the current day with strftime("%A").upper(), which names the day in the process's LC_TIME locale. If the function calls locale.setlocale(locale.LC_TIME, ...) (or LC_ALL) for a non-English locale, the day comes back as FREITAG, VENDREDI, etc., never equals the English names the schema requires, and every day-of-week rule silently stops matching.

Code snippet

import locale
from aws_lambda_powertools.utilities.feature_flags.comparators import compare_days_of_week

cond = {"DAYS": ["FRIDAY"], "TIMEZONE": "UTC"}  # run on a Friday
compare_days_of_week(None, cond)  # True

locale.setlocale(locale.LC_TIME, "de_DE.UTF-8")
compare_days_of_week(None, cond)  # False, the current day is "FREITAG"

Steps to Reproduce

  1. Configure a feature flag rule with SCHEDULE_BETWEEN_DAYS_OF_WEEK and today's day in DAYS.
  2. Set a non-English LC_TIME in the function.
  3. Evaluate the flag: the rule no longer matches.

Possible Solution

Look the day up from datetime.weekday() (Monday is 0) instead of formatting its name, so the result does not depend on the locale. I can open a PR.

Powertools for AWS Lambda (Python) version

latest (develop, 3.38.0)

AWS Lambda function runtime

3.12

Packaging format used

PyPi

Debugging logs

No response

Activity

  1. boring-cyborg commented on Oct 30, 2026

    @boring-cyborg

    Thanks for opening your first issue here! We'll come back to you as soon as we can.
    In the meantime, check out the #python channel on our Powertools for AWS Lambda Discord: Invite link

  2. powertools-for-aws-oss-automation commented on Oct 30, 2026

    @powertools-for-aws-oss-automation

    Thanks for opening your first issue here! We'll come back to you as soon as we can.
    In the meantime, check out our GitHub Discussions: Join the conversation

  3. leandrodamascena commented on Oct 30, 2026

    @leandrodamascena
    Contributor

    Thanks @anishmehta24, confirmed with de_DE here, the day comes back as FREITAG. Honestly most people never touch the locale in Lambda, but comparing against weekday() is the right thing anyway. I'll review #8707. Goes into 3.40.0.

  4. added this to the 3.40.0 milestone on Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingfeature_flagsFeature Flags utility

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions