How to display BST (British Summer Time)?

1,635 views
Skip to first unread message

Daniel Grace

unread,
Oct 17, 2014, 11:14:12 AM10/17/14
to django...@googlegroups.com
Hi,
I have the time zone set as follows:
TIME_ZONE='Europe/London'
USE_TZ = True

This is the same as GMT.  But what I want is BST (British Summer Time) for display purposes, which is UTC + 1 for the "summer" and UTC for the rest of the year.

How do I convert to this the value in my templates?

Thanks.

Kelvin Wong

unread,
Oct 17, 2014, 11:22:37 AM10/17/14
to django...@googlegroups.com

Carl Meyer

unread,
Oct 17, 2014, 11:39:34 AM10/17/14
to django...@googlegroups.com
Hi Daniel,

On 10/17/2014 09:14 AM, Daniel Grace wrote:
> I have the time zone set as follows:
> TIME_ZONE='Europe/London'
> USE_TZ = True
>
> This is the same as GMT. But what I want is BST (British Summer Time)
> for display purposes, which is UTC + 1 for the "summer" and UTC for the
> rest of the year.

According to
http://en.wikipedia.org/wiki/List_of_tz_database_time_zones, the
Europe/London timezone _is_ UTC+1 for the summer and UTC the rest of the
year. So it seems like there may not be anything you need to do.

> How do I convert to this the value in my templates?

If you want all datetimes displayed in a different timezone than your
TIME_ZONE setting (which really only makes sense if you track each
user's timezone and set the active timezone per-request based on the
user - otherwise just set TIME_ZONE to the one you want to use), you use
timezone.activate():
https://docs.djangoproject.com/en/1.7/topics/i18n/timezones/#selecting-the-current-time-zone

Carl

Daniel Grace

unread,
Oct 17, 2014, 11:41:43 AM10/17/14
to django...@googlegroups.com
The date function can only display the offset, it does not actually add the offset to the date time.

Tom Evans

unread,
Oct 17, 2014, 11:43:24 AM10/17/14
to django...@googlegroups.com
'Europe/London' should contain DST transition information, if it is
present in the zone files. So the first question is, where is your
tzdata coming from?

If you have not installed pytz as recommended by the docs, you are
relying on your database and OS to get things right.

For me, with pytz installed, 'Europe/London' has DST info:

>>> import pytz
>>> dt = pytz.timezone('Europe/London')
>>> pprint(dt._utc_transition_times)
[datetime.datetime(1, 1, 1, 0, 0),
datetime.datetime(1901, 12, 13, 20, 45, 52),
datetime.datetime(1916, 5, 21, 2, 0),
datetime.datetime(1916, 10, 1, 2, 0),
datetime.datetime(1917, 4, 8, 2, 0),
....
datetime.datetime(2036, 10, 26, 1, 0),
datetime.datetime(2037, 3, 29, 1, 0),
datetime.datetime(2037, 10, 25, 1, 0)]

Cheers

Tom

Daniel Grace

unread,
Oct 17, 2014, 12:27:08 PM10/17/14
to django...@googlegroups.com
I installed pytz and this problem went away.
Cheers
Reply all
Reply to author
Forward
0 new messages