This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2012年02月02日 20:49 by Roger.Caldwell, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| ctime-doc.patch | harman786, 2016年10月13日 11:12 | patch file | review | |
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 11303 | merged | harman786, 2018年12月24日 09:07 | |
| PR 16022 | merged | miss-islington, 2019年09月12日 10:24 | |
| Messages (16) | |||
|---|---|---|---|
| msg152475 - (view) | Author: Roger Caldwell (Roger.Caldwell) | Date: 2012年02月02日 20:49 | |
Hi. I found this today and thought I would report. I could not find anywhere that it was expected behavior. When using time.ctime() to convert a date which only has 1 digit in the day position it returs a string with 2 spaces after the month vs one.
example
In [2]: import os,time
In [3]: time.ctime(os.path.getmtime('file.cfg'))
Out[3]: 'Tue Dec 13 18:52:58 2011'
In [4]: time.ctime(os.path.getmtime('14d-1.log'))
Out[4]: 'Tue Feb 1 19:53:11 2011'
Is this expected behavior?
|
|||
| msg152483 - (view) | Author: Eric V. Smith (eric.smith) * (Python committer) | Date: 2012年02月02日 22:29 | |
That's definitely the expected behavior. It's the same as the C library version of ctime(). But I couldn't find it documented in the Python docs, so I'm changing this to a documentation issue. Thanks for the report. |
|||
| msg152496 - (view) | Author: Georg Brandl (georg.brandl) * (Python committer) | Date: 2012年02月03日 07:10 | |
asctime() docs say it's a 24 char string. |
|||
| msg153310 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2012年02月14日 00:23 | |
> asctime() docs say it's a 24 char string. I'm not sure that all platform conform to this "specification"... which is not future proof! $ ./python Python 3.3.0a0 (default:af1a9508f7fa, Feb 14 2012, 01:18:15) [GCC 4.6.2 20111027 (Red Hat 4.6.2-1)] on linux >>> import time >>> time.ctime(2**38) 'Wed Jul 14 08:09:04 10680' >>> len(time.ctime(2**38)) 25 I suppose that you can say that the month day is formatted as 2 characters (padded with a space if needed). |
|||
| msg153311 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2012年02月14日 00:25 | |
Or you could give the strftime specification string that produces the equivalent output. |
|||
| msg278557 - (view) | Author: Harmandeep Singh (harman786) * | Date: 2016年10月13日 11:12 | |
I was bored, I generated a patch for this. Hope this helps :) |
|||
| msg332336 - (view) | Author: Antti Haapala (ztane) * | Date: 2018年12月22日 08:32 | |
This should be added to `asctime` too. The space-padded behaviour complies with the C standard which was the intent - after all, before it was using C `asctime` directly, and says that unlike C asctime, it doesn't have the newline character, meaning that as a rule, it should then behave similar to it, and only exception is marked. Unfortunately MSVC asctime has been incorrectly using leading zeros (https://stackoverflow.com/q/53894148/918959). |
|||
| msg332422 - (view) | Author: Harmandeep Singh (harman786) * | Date: 2018年12月24日 09:07 | |
I have created the PR as mentioned, I have added the example for time.ctime() and also added the note to time.asctime. |
|||
| msg332584 - (view) | Author: Harmandeep Singh (harman786) * | Date: 2018年12月27日 11:08 | |
I have created a PR for the patch that I submitted, as this is my first contribution to the docs, I need to know that how do we decide if a change has to make an entry to `Misc/NEWS.d/next/` or needs `skip news` tag? |
|||
| msg339973 - (view) | Author: Cheryl Sabella (cheryl.sabella) * (Python committer) | Date: 2019年04月11日 13:18 | |
I would like to help get this issue merged as it's already been approved by a core developer. Does anyone object to the change? Victor made a suggestion on the PR for alternative wording and I wanted to give others a chance to comment on that. Also, looking at the man page for asctime, they use `Www Mmm dd hh:mm:ss yyyy` as the description of the output. Maybe it would be helpful to add this since it shows the spacing and explicitly shows the day number taking up 2 characters? Thanks! |
|||
| msg339975 - (view) | Author: Harmandeep Singh (harman786) * | Date: 2019年04月11日 13:48 | |
This is not python compatible format, I want something like "%a %b %d %H:%M:%S %Y" to explain it. |
|||
| msg339980 - (view) | Author: Cheryl Sabella (cheryl.sabella) * (Python committer) | Date: 2019年04月11日 14:38 | |
I guess what I'm thinking of `Www Mmm dd hh:mm:ss yyyy` as representing isn't so much a format, but rather a literal replacement of where each value has a placeholder in the string (that is, a pattern). So, even if `Www` doesn't mean anything, to me it means that the first three characters in the string are a Weekday, then there's a space, then Mmm is the month, then a space, then dd is the day number (with zero sometimes suppressed), etc. If that is more confusing than not using it, then that's fine. I just wanted to mention it. Using %d to me is also confusing since the docs define %d as `Day of the month as a decimal number [01,31]`. This clearly isn't using 01, but rather suppressing the 0. |
|||
| msg340207 - (view) | Author: Harmandeep Singh (harman786) * | Date: 2019年04月14日 13:54 | |
I have updated the PR, this time I have kept it really simple, and have added examples showing both the cases. |
|||
| msg352091 - (view) | Author: Paul Ganssle (p-ganssle) * (Python committer) | Date: 2019年09月12日 10:22 | |
New changeset 2d32bf1ef23c9e468b2e8afab3c24e7a2047ac36 by Paul Ganssle (Harmandeep Singh) in branch 'master': bpo-13927: time.ctime and time.asctime return string explantion (GH-11303) https://github.com/python/cpython/commit/2d32bf1ef23c9e468b2e8afab3c24e7a2047ac36 |
|||
| msg352095 - (view) | Author: miss-islington (miss-islington) | Date: 2019年09月12日 10:31 | |
New changeset 1e17c4d414049ad2b5b6a0a53685efc7a550c5c5 by Miss Islington (bot) in branch '3.8': bpo-13927: time.ctime and time.asctime return string explantion (GH-11303) https://github.com/python/cpython/commit/1e17c4d414049ad2b5b6a0a53685efc7a550c5c5 |
|||
| msg352098 - (view) | Author: Paul Ganssle (p-ganssle) * (Python committer) | Date: 2019年09月12日 10:35 | |
We've merged the PR and I think it resolves this issue, so we can close this issue now. Please let me know if it's not fully resolved and we can re-open. Thanks Roger for reporting this and Harmandeep for making the PR and requested changes. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:26 | admin | set | github: 58135 |
| 2019年09月12日 10:35:48 | p-ganssle | set | status: open -> closed type: behavior -> enhancement messages: + msg352098 resolution: fixed stage: patch review -> resolved |
| 2019年09月12日 10:31:46 | miss-islington | set | nosy:
+ miss-islington messages: + msg352095 |
| 2019年09月12日 10:24:53 | miss-islington | set | pull_requests: + pull_request15645 |
| 2019年09月12日 10:22:33 | p-ganssle | set | nosy:
+ p-ganssle messages: + msg352091 |
| 2019年04月14日 13:54:43 | harman786 | set | messages: + msg340207 |
| 2019年04月11日 14:38:05 | cheryl.sabella | set | messages: + msg339980 |
| 2019年04月11日 13:48:02 | harman786 | set | messages: + msg339975 |
| 2019年04月11日 13:18:54 | cheryl.sabella | set | nosy:
+ cheryl.sabella, belopolsky messages: + msg339973 |
| 2019年01月04日 23:19:25 | vstinner | set | title: Extra spaces in the output of time.ctime -> Document time.ctime format versions: - Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6 |
| 2018年12月27日 11:08:41 | harman786 | set | nosy:
- docs@python messages: + msg332584 |
| 2018年12月24日 09:07:15 | harman786 | set | versions:
+ Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8 stage: patch review messages: + msg332422 pull_requests: + pull_request10527 |
| 2018年12月22日 08:32:44 | ztane | set | nosy:
+ ztane messages: + msg332336 |
| 2018年09月12日 03:47:50 | martin.panter | link | issue34642 superseder |
| 2016年10月13日 11:16:02 | harman786 | set | hgrepos: - hgrepo360 |
| 2016年10月13日 11:12:50 | harman786 | set | files:
+ ctime-doc.patch nosy: + harman786 messages: + msg278557 hgrepos: + hgrepo360 keywords: + patch |
| 2012年02月14日 00:25:56 | r.david.murray | set | nosy:
+ r.david.murray messages: + msg153311 |
| 2012年02月14日 00:23:26 | vstinner | set | nosy:
+ vstinner messages: + msg153310 |
| 2012年02月03日 07:10:51 | georg.brandl | set | nosy:
+ georg.brandl messages: + msg152496 |
| 2012年02月02日 22:29:28 | eric.smith | set | versions:
+ Python 3.2, Python 3.3 nosy: + docs@python, eric.smith messages: + msg152483 assignee: docs@python components: + Documentation, - None |
| 2012年02月02日 20:49:35 | Roger.Caldwell | create | |