Fixed #20693 -- Add timezone support to built-in time filter. #1327

Merged
merged 1 commit into from Aug 26, 2013

Conversation

Projects
None yet
3 participants
@wsmith323
Contributor

wsmith323 commented Jul 3, 2013

Modified django.utils.dateformat module, moving init() method and
timezone-related format methods from DateFormat class to TimeFormat
base class. Modified timezone-related format methods to return an
empty string when timezone is inappropriate for input value.

@estebistec

View changes

tests/template_tests/filters.py
+ # Ticket 20693: Add timezone support to built-in time template filter
+ 'time01': (r'{{ dt|time:"P:e:O:T:Z" }}', {'dt': datetime(2013, 7, 2, 4, 0, tzinfo=FixedOffset(30))}, '4 a.m.:+0030:+0030:+0030:1800'),
+ 'time02': (r'{{ dt|time:"P:e:O:T:Z" }}', {'dt': datetime(2013, 7, 2)}, 'midnight::-0500:CDT:-18000'),
+ 'time03': (r'{{ t|time:"P:e:O:T:Z" }}', {'t': time(4, 0, tzinfo=FixedOffset(30))}, '4 a.m.::::'),

This comment has been minimized.

@estebistec

estebistec Jul 14, 2013

Is datetime.date covered elsewhere?

@estebistec

estebistec Jul 14, 2013

Is datetime.date covered elsewhere?

This comment has been minimized.

@wsmith323

wsmith323 Jul 15, 2013

Contributor

I've added a test for datetime.date. The results are not any different than for any other object that doesn't contain time information, but it is better to handle that case explicitly.

I also realized that the time02 test contained success criteria that was not portable. I have fixed that.

@wsmith323

wsmith323 Jul 15, 2013

Contributor

I've added a test for datetime.date. The results are not any different than for any other object that doesn't contain time information, but it is better to handle that case explicitly.

I also realized that the time02 test contained success criteria that was not portable. I have fixed that.

@estebistec

View changes

django/utils/dateformat.py
+ timezones west of UTC is always negative, and for those east of UTC is
+ always positive.
+ """
+ if not self.timezone:

This comment has been minimized.

@estebistec

estebistec Jul 28, 2013

For this and all of the above methods, the docstring should be enhanced to explain the case that returns blank.

@estebistec

estebistec Jul 28, 2013

For this and all of the above methods, the docstring should be enhanced to explain the case that returns blank.

This comment has been minimized.

@wsmith323

wsmith323 Jul 29, 2013

Contributor

I have added the doctsring modifications you suggested.

@wsmith323

wsmith323 Jul 29, 2013

Contributor

I have added the doctsring modifications you suggested.

@estebistec

This comment has been minimized.

Show comment
Hide comment
@estebistec

estebistec Jul 28, 2013

Sorry for the late comment. It is my belief that after this change it would be ready for checkin (and I'll mark it as such).

Sorry for the late comment. It is my belief that after this change it would be ready for checkin (and I'll mark it as such).

Fixed #20693 -- Add timezone support to built-in time filter.
Modified django.utils.dateformat module, moving __init__() method and
timezone-related format methods from DateFormat class to TimeFormat
base class. Modified timezone-related format methods to return an
empty string when timezone is inappropriate for input value.

@carljm carljm merged commit dd3a883 into django:master Aug 26, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment