Re: [Django] #17992: Public API for localtime

2012-04-29 Thread Django
#17992: Public API for localtime
-+-
 Reporter:  Bradley Ayers|Owner:  aaugustin
    |   Status:  closed
 Type:  New feature  |  Version:  1.4
Component:   |   Resolution:  fixed
  Internationalization   | Triage Stage:  Accepted
 Severity:  Normal   |  Needs documentation:  0
 Keywords:  timezone localtime   |  Patch needs improvement:  0
Has patch:  0|UI/UX:  0
  Needs tests:  0|
Easy pickings:  0|
-+-
Changes (by aaugustin):

 * status:  new => closed
 * resolution:   => fixed


Comment:

 FIxed in 3e8b40f479a02e0f8c40ef3c7dae740082478b89.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #17992: Public API for localtime

2012-03-28 Thread Django
#17992: Public API for localtime
-+-
 Reporter:  Bradley Ayers|Owner:  nobody
    |   Status:  new
 Type:  New feature  |  Version:  1.4
Component:  Core (Other) |   Resolution:
 Severity:  Normal   | Triage Stage:  Accepted
 Keywords:  timezone localtime   |  Needs documentation:  0
Has patch:  0|  Patch needs improvement:  0
  Needs tests:  0|UI/UX:  0
Easy pickings:  0|
-+-
Description changed by aaugustin:

Old description:

> I think there should be a public API for converting timezone aware
> datetime objects to current timezone versions. This actually existed in
> django.utils.timezone as localtime, but was made private and removed from
> the documentation in https://code.djangoproject.com/changeset/17642
>
> The current options for converting a datetime to the current timezone
> are:
>
> 1. Use Python's datetime.astimezone in conjunction with
> django.utils.timezone helpers:
>
> {{{
> from django.utils import timezone
> local = dt.astimezone(timezone.get_current_timezone())
> }}}
>
> 2. Use the public API for the localtime template filter via the privatish
> module django.template.defaultfilters:
>
> {{{
> from django.template.defaultfilters import localtime
> local = localtime(dt)
> }}}
>
> While (2) is much cleaner, I'd argue it's dirty to import from
> defaultfilters.
>
> I propose re-publicising django.utils.timezone.localtime as a public API.
>
> My use-case is generating PDFs that have datetimes in their content.

New description:

 I think there should be a public API for converting timezone aware
 datetime objects to current timezone versions. This actually existed in
 django.utils.timezone as localtime, but was made private and removed from
 the documentation in https://code.djangoproject.com/changeset/17642

 The current options for converting a datetime to the current timezone are:

 1. Use Python's datetime.astimezone in conjunction with
 django.utils.timezone helpers:

 {{{
 from django.utils import timezone
 local = dt.astimezone(timezone.get_current_timezone())
 }}}

 2. Use the public API for the localtime template filter via the privatish
 module django.template.defaultfilters:

 {{{
 from django.templatetags.tz import localtime
 local = localtime(dt)
 }}}

 While (2) is much cleaner, I'd argue it's dirty to import from
 defaultfilters.

 I propose re-publicising django.utils.timezone.localtime as a public API.

 My use-case is generating PDFs that have datetimes in their content.

--

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #17992: Public API for localtime

2012-03-28 Thread Django
#17992: Public API for localtime
-+-
 Reporter:  Bradley Ayers|Owner:  aaugustin
    |   Status:  new
 Type:  New feature  |  Version:  1.4
Component:  Core (Other) |   Resolution:
 Severity:  Normal   | Triage Stage:  Accepted
 Keywords:  timezone localtime   |  Needs documentation:  0
Has patch:  0|  Patch needs improvement:  0
  Needs tests:  0|UI/UX:  0
Easy pickings:  0|
-+-
Changes (by aaugustin):

 * owner:  nobody => aaugustin


Comment:

 Anssi suggests that `localtime` should use the current time zone, which
 can be explicitly changed if necessary.

 This would resolve the most common use case, and mirror the behavior of
 the template engine.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #17992: Public API for localtime

2012-03-28 Thread Django
#17992: Public API for localtime
-+-
 Reporter:  Bradley Ayers|Owner:  aaugustin
    |   Status:  new
 Type:  New feature  |  Version:  1.4
Component:   |   Resolution:
  Internationalization   | Triage Stage:  Accepted
 Severity:  Normal   |  Needs documentation:  0
 Keywords:  timezone localtime   |  Patch needs improvement:  0
Has patch:  0|UI/UX:  0
  Needs tests:  0|
Easy pickings:  0|
-+-
Changes (by jezdez):

 * component:  Core (Other) => Internationalization


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #17992: Public API for localtime

2012-03-28 Thread Django
#17992: Public API for localtime
-+-
 Reporter:  Bradley Ayers|Owner:  nobody
    |   Status:  new
 Type:  New feature  |  Version:  1.4
Component:  Core (Other) |   Resolution:
 Severity:  Normal   | Triage Stage:  Accepted
 Keywords:  timezone localtime   |  Needs documentation:  0
Has patch:  0|  Patch needs improvement:  0
  Needs tests:  0|UI/UX:  0
Easy pickings:  0|
-+-
Changes (by aaugustin):

 * stage:  Unreviewed => Accepted


Comment:

 I made `django.utils.timezone.localtime` private because it contains some
 template-specific code.

 I agree it would make sense to expose a similar function, without the
 template-specific bits, for general use.

 This function actually has two variants: "default local time" or "current
 local time". As long as you don't have a timezone switcher for your end
 users, there's no difference between these. However, we should take this
 into account while extending the public API.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #17992: Public API for localtime

2012-03-27 Thread Django
#17992: Public API for localtime
-+-
 Reporter:  Bradley Ayers|Owner:  nobody
    |   Status:  new
 Type:  New feature  |  Version:  1.4
Component:  Core (Other) |   Resolution:
 Severity:  Normal   | Triage Stage:
 Keywords:  timezone localtime   |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Bradley Ayers ):

 * needs_docs:   => 0
 * needs_tests:   => 0
 * needs_better_patch:   => 0


Comment:

 Correction:

 {{{
 django.template.defaultfilters import localtime
 }}}

 …should have been:

 {{{
 from django.templatetags.tz import localtime
 }}}

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



[Django] #17992: Public API for localtime

2012-03-27 Thread Django
#17992: Public API for localtime
-+-
 Reporter:  Bradley Ayers   |  Owner:  nobody
 Type:  New feature  | Status:  new
Component:  Core (Other) |Version:  1.4
 Severity:  Normal   |   Keywords:  timezone
 Triage Stage:  Unreviewed   |  localtime
Easy pickings:  0|  Has patch:  0
 |  UI/UX:  0
-+-
 I think there should be a public API for converting timezone aware
 datetime objects to current timezone versions. This actually existed in
 django.utils.timezone as localtime, but was made private and removed from
 the documentation in https://code.djangoproject.com/changeset/17642

 The current options for converting a datetime to the current timezone are:

 1. Use Python's datetime.astimezone in conjunction with
 django.utils.timezone helpers:

 {{{
 from django.utils import timezone
 local = dt.astimezone(timezone.get_current_timezone())
 }}}

 2. Use the public API for the localtime template filter via the privatish
 module django.template.defaultfilters:

 {{{
 from django.template.defaultfilters import localtime
 local = localtime(dt)
 }}}

 While (2) is much cleaner, I'd argue it's dirty to import from
 defaultfilters.

 I propose re-publicising django.utils.timezone.localtime as a public API.

 My use-case is generating PDFs that have datetimes in their content.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.