Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docstrings to time.struct_time #53145

Closed
abalkin opened this issue Jun 4, 2010 · 5 comments
Closed

Add docstrings to time.struct_time #53145

abalkin opened this issue Jun 4, 2010 · 5 comments
Assignees
Labels
docs Documentation in the Doc dir easy type-feature A feature request or enhancement

Comments

@abalkin
Copy link
Member

abalkin commented Jun 4, 2010

BPO 8899
Nosy @birkenfeld, @mdickinson, @abalkin
Files
  • struct_time_doc.diff: Patch for trunk
  • issue8899.diff
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/abalkin'
    closed_at = <Date 2010-06-05.15:13:29.166>
    created_at = <Date 2010-06-04.19:47:16.092>
    labels = ['easy', 'type-feature', 'docs']
    title = 'Add docstrings to time.struct_time'
    updated_at = <Date 2010-06-05.15:13:29.165>
    user = 'https://github.com/abalkin'

    bugs.python.org fields:

    activity = <Date 2010-06-05.15:13:29.165>
    actor = 'belopolsky'
    assignee = 'belopolsky'
    closed = True
    closed_date = <Date 2010-06-05.15:13:29.166>
    closer = 'belopolsky'
    components = ['Documentation']
    creation = <Date 2010-06-04.19:47:16.092>
    creator = 'belopolsky'
    dependencies = []
    files = ['17556', '17557']
    hgrepos = []
    issue_num = 8899
    keywords = ['patch', 'easy']
    message_count = 5.0
    messages = ['107089', '107096', '107099', '107101', '107138']
    nosy_count = 4.0
    nosy_names = ['georg.brandl', 'mark.dickinson', 'belopolsky', 'docs@python']
    pr_nums = []
    priority = 'normal'
    resolution = 'accepted'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue8899'
    versions = ['Python 2.7', 'Python 3.2']

    @abalkin
    Copy link
    Member Author

    abalkin commented Jun 4, 2010

    The time.struct_time class is missing class and field docstrings:

    >>> time.struct_time.__doc__ is None
    True
    >>> time.struct_time.tm_year.__doc__ is None
    True

    This is significant because it is not obvious that field values are different from those of C language struct tm fields with the same names. (While module level docstring describes the timetuple, it does not list the names of the struct_time fields or mentions struct_time.)

    With the attached patch,

    >>> from time import *
    >>> localtime()
    time.struct_time(tm_year=2010, tm_mon=6, tm_mday=4, tm_hour=15, tm_min=27, tm_sec=15, tm_wday=4, tm_yday=155, tm_isdst=1)
    >>> help(_)
    Help on struct_time object:
    time.struct_time = class struct_time(__builtin__.object)
     |  The time value as returned by gmtime(), localtime(), and strptime(), and accepted
     |  by asctime(), mktime() and strftime(), may be considered as a sequence of 9 integers.
     |  Note that several fields' values are not the same as those defined by the C language
     |  standard for struct tm.  For example, the value of tm_year is the actual year, not
     |  year - 1900.   See individual fields' descriptions for details.
    ...
     |  

    | Data descriptors defined here:
    |
    | tm_hour
    | hours, range [0 - 23]
    |
    | tm_isdst
    | 1 if summer time is in effect, 0 if not, and -1 if cannot be determined
    |
    | tm_mday
    | day of month, range [1 - 31]
    |
    | tm_min
    | minutes, range [0 - 59]
    |
    | tm_mon
    | month of year, range [1 - 12]
    |
    | tm_sec
    | seconds, range [0 - 61])
    |
    | tm_wday
    | day of week, range [0,6], Monday is 0
    |
    | tm_yday
    | day of year, range [1,366]
    |
    | tm_year
    | year, for example, 1993
    |
    | ----------------------------------------------------------------------

    @abalkin abalkin self-assigned this Jun 4, 2010
    @abalkin abalkin added docs Documentation in the Doc dir easy type-feature A feature request or enhancement labels Jun 4, 2010
    @birkenfeld
    Copy link
    Member

    Patch review:

    • Quite a few lines are pretty long. Please stay below 80 chars/line.
    • There are trailing spaces in two member docs.
    • The range notation is inconsistent. [first, last] or [first, last+1) is what we generally use.
    • "if cannot be determined" does not sound grammatical, maybe just "unknown" is better.
    • Between "strftime()" and "may be considered" the sentence should be split.

    @abalkin
    Copy link
    Member Author

    abalkin commented Jun 4, 2010

    Please see fixes in bpo-8899.diff.

    • Quite a few lines are pretty long. Please stay below 80 chars/line.

    Fixed.

    • There are trailing spaces in two member docs.

    Fixed.

    • The range notation is inconsistent. [first, last] or [first, last+1) is what we generally use.

    Fixed in docstrings and time.rst.

    • "if cannot be determined" does not sound grammatical, maybe just "unknown" is better.

    Fixed. POSIX spec uses "if the information is not available", but I like

    • Between "strftime()" and "may be considered" the sentence should be split.

    Fixed in docstrings and time.rst.

    @birkenfeld
    Copy link
    Member

    The first change in time.rst is not needed; there the sentence is not a direct description of struct_time. The rest is good to commit.

    @abalkin
    Copy link
    Member Author

    abalkin commented Jun 5, 2010

    Committed in r81756 (trunk) and r81757 (py3k).

    @abalkin abalkin closed this as completed Jun 5, 2010
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    docs Documentation in the Doc dir easy type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants