Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#33664 closed Bug (duplicate)

Timezones with hyphens in name fail in Extract() functions.

Reported by: Doug Franklin Owned by: nobody
Component: Database layer (models, ORM) Version: 3.2
Severity: Normal Keywords: timezone extract hyphen
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

local_tz = pytz.timezone(""Asia/Ust-Nera")
models = Model.objects.annotate(
    created_at_month=ExtractMonth('created_at', tzinfo=local_tz)
)

When evaluating the queryset it fails with:

DataError: time zone "Asia/Ust+Nera" not recognized

The "+" in "Asia/Ust+Nera" is suspicious.I have confirmed this fails with other timezones with hyphens, such as "America/Port-au-Prince".

I have also confirmed my postgresql DB supports these timezones:

SELECT
    name,
    abbrev,
    utc_offset,
    is_dst
FROM pg_timezone_names
WHERE name !~ 'posix'
ORDER BY name asc;
```
Asia/Ust-Nera                    | +10    | 10:00:00   | f
...
America/Port-au-Prince           | EDT    | -04:00:00  | t
```

Change History (1)

comment:1 by Mariusz Felisiak, 3 years ago

Component: UncategorizedDatabase layer (models, ORM)
Resolution: duplicate
Status: newclosed
Type: UncategorizedBug

Duplicate of #33663.

Version 0, edited 3 years ago by Mariusz Felisiak (next)
Note: See TracTickets for help on using tickets.
Back to Top