Re: time, calendar, datetime, etc

Discussion in 'Python' started by Ben S, Jul 31, 2003.

  1. Ben S

    Ben S Guest

    Steven Taschuk wrote:
    > Quoth Kylotan:
    > [...]
    >> And does datetime.timetuple() actually return something equivalent to
    >> a struct_time as used by the time module? At first glance this looks
    >> to be true, but it isn't clearly documented as such.

    >
    > Isn't it?
    >
    > timetuple()
    > Return a 9-element tuple of the form returned by
    > time.localtime().
    >
    > <http://www.python.org/doc/current/lib/datetime-datetime.html>


    Problem is, time.localtime() doesn't return a 9-element tuple any more,
    it returns a struct_time. (Since 2.2, I think.)

    --
    Ben Sizer
    http://pages.eidosnet.co.uk/kylotan
    Ben S, Jul 31, 2003
    #1
    1. Advertising

  2. Ben S

    John Roth Guest

    "Ben S" <> wrote in message
    news:bgaphh$lua$...
    > Steven Taschuk wrote:
    > > Quoth Kylotan:
    > > [...]
    > >> And does datetime.timetuple() actually return something equivalent to
    > >> a struct_time as used by the time module? At first glance this looks
    > >> to be true, but it isn't clearly documented as such.

    > >
    > > Isn't it?
    > >
    > > timetuple()
    > > Return a 9-element tuple of the form returned by
    > > time.localtime().
    > >
    > > <http://www.python.org/doc/current/lib/datetime-datetime.html>

    >
    > Problem is, time.localtime() doesn't return a 9-element tuple any more,
    > it returns a struct_time. (Since 2.2, I think.)


    Strictly speaking, that's true, but the object that's returned
    *acts* like a sequence of 9 integers if you reference it properly.
    It seems like 2.2 did this in a number of places, so that you
    could reference values by name. I like the thinking behind it.
    It's a lot better documentation if you want to get one value at
    a time.

    John Roth

    >
    > --
    > Ben Sizer
    > http://pages.eidosnet.co.uk/kylotan
    >
    >
    John Roth, Jul 31, 2003
    #2
    1. Advertising

  3. Quoth Ben S:
    [...]
    > Problem is, time.localtime() doesn't return a 9-element tuple any more,
    > it returns a struct_time. (Since 2.2, I think.)


    Ah, yes. I read Kylotan's question pretty sloppily, it seems.

    datetime.timetuple() does indeed return a struct_time, as do
    date.timetuple() and datetime.utctimetuple(), and this is clearly
    desirable and intended. I think I'll submit a doc patch.

    --
    Steven Taschuk o- @
    7O )
    " (
    Steven Taschuk, Aug 1, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ben S
    Replies:
    16
    Views:
    729
    John Roth
    Aug 4, 2003
  2. Tim Peters

    RE: time, calendar, datetime, etc

    Tim Peters, Aug 2, 2003, in forum: Python
    Replies:
    3
    Views:
    299
    John Roth
    Aug 3, 2003
  3. Tim Peters

    RE: time, calendar, datetime, etc

    Tim Peters, Aug 3, 2003, in forum: Python
    Replies:
    3
    Views:
    357
    John Baxter
    Aug 5, 2003
  4. Christos TZOTZIOY Georgiou
    Replies:
    3
    Views:
    691
    Christos TZOTZIOY Georgiou
    Sep 13, 2003
  5. Tim Peters
    Replies:
    0
    Views:
    524
    Tim Peters
    Sep 9, 2003
Loading...

Share This Page