Skip to content

add datetime.time.now() for consistency #53148

Closed

Description

@techtonik
mannequin
BPO 8902
Nosy @malemburg, @rhettinger, @ronaldoussoren, @abalkin, @ezio-melotti, @bitdancer

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 2014-06-30.07:21:50.488>
created_at = <Date 2010-06-05.06:36:25.988>
labels = ['easy', 'type-feature', 'library']
title = 'add datetime.time.now() for consistency'
updated_at = <Date 2014-06-30.08:33:04.148>
user = 'https://bugs.python.org/techtonik'

bugs.python.org fields:

activity = <Date 2014-06-30.08:33:04.148>
actor = 'berker.peksag'
assignee = 'belopolsky'
closed = True
closed_date = <Date 2014-06-30.07:21:50.488>
closer = 'rhettinger'
components = ['Library (Lib)']
creation = <Date 2010-06-05.06:36:25.988>
creator = 'techtonik'
dependencies = []
files = []
hgrepos = []
issue_num = 8902
keywords = ['easy']
message_count = 11.0
messages = ['107122', '107166', '107191', '107192', '107331', '118216', '162455', '162460', '162461', '221909', '221946']
nosy_count = 7.0
nosy_names = ['lemburg', 'rhettinger', 'ronaldoussoren', 'belopolsky', 'techtonik', 'ezio.melotti', 'r.david.murray']
pr_nums = []
priority = 'low'
resolution = 'rejected'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue8902'
versions = ['Python 3.5']

Activity

  1. techtonik commented on Jun 5, 2010

    techtonikmannequin
    MannequinAuthor

    There is:
    datetime.date.today()
    datetime.datetime.today()
    datetime.datetime.now([tz])

    But no:
    datetime.time.now([tz])

  2. added
    stdlib
    on Jun 5, 2010
  3. abalkin commented on Jun 6, 2010

    @abalkin
    Member

    Anatoly,

    Didn't you just recently complain about the large number of functions in datetime module? (bpo-7584)

    datetime.datetime.now().time() seems adequate to me.

    What is your use case?

  4. self-assigned this
    on Jun 6, 2010
  5. techtonik commented on Jun 6, 2010

    techtonikmannequin
    MannequinAuthor

    What is your use case?

    >>> from datetime import now, today
    >>> now()
    datetime.time ...
    >>> today()
    datetime.date ...
  6. techtonik commented on Jun 6, 2010

    techtonikmannequin
    MannequinAuthor

    Didn't you just recently complain about the large number of functions in datetime module?

    About verbosity of datetime API to be exact, so it is a ratio of (API functions + required docs)/user code that makes required stuff done.

  7. abalkin commented on Jun 8, 2010

    @abalkin
    Member

    Anatoly,

    msg107191 belongs to bpo-8903, not here and it is not a use case, but rather a demonstration of how the proposed feature would work.

    My question is why would an application need current time without current date? I feel providing time.now() may lead so people to call date.today() and time.now() separately instead of datetime.now() leading to interesting bugs.

    One think I would consider an improvement over the current situation, would be to rename date.today() to date.now(). There are too many ways to spell the same thing:

    date.today()
    datetime.today()
    datetime.now().date()

    and no easy way to write a "how long ago" function that would work for both date and datetime:

    def ago(t):
        t.now() - t
  8. abalkin commented on Oct 8, 2010

    @abalkin
    Member

    I need to correct myself: datetime.today() is not an alternative spelling of date.today(), but rather a function returning current datetime which subtly different from datetime.now().

  9. added
    type-feature
    on Oct 8, 2010
  10. abalkin commented on Jun 7, 2012

    @abalkin
    Member

    Closing for the lack of interest. Proposed time.now() is already available as datetime.now().time(). No use case justifying any improvement in this area was presented.

  11. techtonik commented on Jun 7, 2012

    techtonikmannequin
    MannequinAuthor

    I'd say no consensus was reached due to lack of participation. My enthusiasm was killed by the bpo-8903 resolution.

    My opinion is that:
    datetime.time.now()
    is much better than:
    datetime.datetime.now().time()

  12. techtonik commented on Jun 7, 2012

    techtonikmannequin
    MannequinAuthor

    And I certainly don't agree with you that usability changes in API are not use cases.

  13. reopened this on Jun 5, 2013
  14. abalkin commented on Jun 29, 2014

    @abalkin
    Member

    I would like to bring this issue to some conclusion. Here is the summary:

    Pro:

    datetime.time.now() is shorter than datetime.datetime.now().time()

    Cons:

    1. date, time = datetime.date.today(), datetime.time.now() is attractive, but wrong.

    2. time detached from date is a strange object with limited support in datetime module (no timedelta arithmetics, bpo-17267; tzinfo issues; etc.)

    3. No compelling use cases have been presented.

  15. rhettinger commented on Jun 30, 2014

    @rhettinger
    Contributor

    For the reasons listed by others, marking this as closed/rejected.

  16. transferred this issue fromon Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

easystdlibtype-feature

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions