Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #88195

Re: time module vs. datetime module: plain language for beginners

References <bc879cba-ef09-48e0-a52f-c0fc87710729@googlegroups.com> <8e4f3547-092d-4067-8022-5e911a39680f@googlegroups.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date 2015-03-27 19:07 -0600
Subject Re: time module vs. datetime module: plain language for beginners
Newsgroups comp.lang.python
Message-ID <mailman.284.1427504897.10327.python-list@python.org> (permalink)

Show all headers | View raw


On Fri, Mar 27, 2015 at 6:31 PM, Jinghui Niu <niujinghui@gmail.com> wrote:
> On Wednesday, March 25, 2015 at 2:17:03 PM UTC-7, Jinghui Niu wrote:
>> I am learning python programming. One thing that gives me a lot of confusion is the division of labours between the time module and the datetime module.
>>
>> As it turns out to be, time module is not only about time, it's about date too. And datetime doesn't natively support timezone, you have to create one for yourself.
>>
>> Why duplicate datetime module? What is the design rationale between this division? Can't we just have one unified module that deals with dates and times? Could someone please list some situations where the two modules are actually useful in their own ways respectively?
>>
>> Explanation with not too much jargon is highly appreciated. Thanks in advance.
>
> Thank you all very much for such a great explanation. I have a follow-up question here: what is the best practice in dealing with repeating date/time? I see neither date module nore datetime module natively supports such datatype right now. Thanks.

Do you mean recurrence rules like "every three hours" or "every two
weeks" or "the third Saturday of every month"? There's nothing
specific in the standard library for this, but check out the
python-dateutil third-party package, specifically the dateutil.rrule
module.

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

time module vs. datetime module: plain language for beginners Jinghui Niu <niujinghui@gmail.com> - 2015-03-25 14:16 -0700
  Re: time module vs. datetime module: plain language for beginners Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-03-26 10:36 +1100
  Re: time module vs. datetime module: plain language for beginners Ian Kelly <ian.g.kelly@gmail.com> - 2015-03-25 17:49 -0600
  Re: time module vs. datetime module: plain language for beginners Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-03-26 00:01 +0000
  Re: time module vs. datetime module: plain language for beginners Jinghui Niu <niujinghui@gmail.com> - 2015-03-27 17:31 -0700
    Re: time module vs. datetime module: plain language for beginners Ian Kelly <ian.g.kelly@gmail.com> - 2015-03-27 19:07 -0600

csiph-web