Why is this needed? When would a real app use %Z%z?
On Wed, Aug 26, 2015 at 7:01 AM, Alexander Belopolsky <
[email protected]> wrote:
> As a little diversion from the PEP wars, let me ask the group if we can
> fix this little wart: [1]
>
> >>> from datetime import *
> >>> t = datetime.now(timezone.utc)
> >>> print(t)
> 2015-08-26 13:37:18.729831+00:00
> >>> t.strftime("%F %T %Z%z")
> '2015-08-26 13:37:18 UTC+00:00+0000'
>
> The reason for such an odd result is that the "name" of timezone.utc was
> defined as
>
> >>> t.tzname()
> 'UTC+00:00'
>
> I don't think there was any deep reason for this choice. We simply have
> one common rule for forming the names of all fixed offset timezones that
> don't have a name supplied in the constructor:
>
> >>> print(timezone(-5*HOUR))
> UTC-05:00
>
> For technical reasons, we cannot give timezone.utc a name, but I think we
> can change the rules for forming fixed offset timezone names so that zeros
> are not printed and instead of
>
> >>> print(timezone(0*HOUR))
> UTC+00:00
>
> we have
>
> >>> print(timezone(0*HOUR))
> UTC
>
>
> [1]: http://bugs.python.org/issue22241
>
> _______________________________________________
> Datetime-SIG mailing list
> [email protected]
> https://mail.python.org/mailman/listinfo/datetime-sig
> The PSF Code of Conduct applies to this mailing list:
> https://www.python.org/psf/codeofconduct/
>
--
--Guido van Rossum (python.org/~guido)
_______________________________________________
Datetime-SIG mailing list
[email protected]
https://mail.python.org/mailman/listinfo/datetime-sig
The PSF Code of Conduct applies to this mailing list:
https://www.python.org/psf/codeofconduct/