Creating a timedelta counter...

Discussion in 'Python' started by Wil Schultz, Jul 20, 2004.

  1. Wil Schultz

    Wil Schultz Guest

    Hey all,
    Sorry, I am trying my best to learn python and seem to be able to grab
    somethings while others seem to escape me...

    I am trying to write a timedelta meter, i.e. "it has been U years, V
    months, W day's, X hours, Y minutes, Z seconds since SomePoint"

    Here's what I have so far, I can print the current time/date but am
    having issues figuring out how to timedelat it...

    ____________________________________________________
    # dunno about this
    from datetime import datetime, timedelta

    # This works, will print date/time

    from time import gmtime, strftime
    strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime())


    # sometime
    myYear = "2004"
    myMonth = "7"
    myDay = "8"
    myHour = "6"
    myMinute = "21"
    mySecond = "13"
    -----------------------------------------------------

    --
    Wil
    my 2¢

    "When everything seems to be going well, you have obviously overlooked
    something."
    Wil Schultz, Jul 20, 2004
    #1
    1. Advertising

  2. Wil Schultz

    Adonis Guest

    "Wil Schultz" <> wrote in message
    news:...
    > Hey all,
    > Sorry, I am trying my best to learn python and seem to be able to grab
    > somethings while others seem to escape me...
    >
    > I am trying to write a timedelta meter, i.e. "it has been U years, V
    > months, W day's, X hours, Y minutes, Z seconds since SomePoint"
    >
    > Here's what I have so far, I can print the current time/date but am
    > having issues figuring out how to timedelat it...
    >
    > ____________________________________________________
    > # dunno about this
    > from datetime import datetime, timedelta
    >
    > # This works, will print date/time
    >
    > from time import gmtime, strftime
    > strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime())
    >
    >
    > # sometime
    > myYear = "2004"
    > myMonth = "7"
    > myDay = "8"
    > myHour = "6"
    > myMinute = "21"
    > mySecond = "13"
    > -----------------------------------------------------
    >
    > --
    > Wil
    > my 2¢
    >
    > "When everything seems to be going well, you have obviously overlooked
    > something."


    Check out the datemtime module, in particular the timedelta class.
    Hope this helps.

    http://www.python.org/doc/current/lib/module-datetime.html

    Adonis
    Adonis, Jul 20, 2004
    #2
    1. Advertising

  3. Wil Schultz

    Wil Schultz Guest

    Thanks, after much pounding I got it worked out... somewhat anyway! ;)

    Wil
    my 2¢

    "When everything seems to be going well, you have obviously overlooked
    something."


    Adonis wrote:
    > "Wil Schultz" <> wrote in message
    > news:...
    >
    >>Hey all,
    >>Sorry, I am trying my best to learn python and seem to be able to grab
    >>somethings while others seem to escape me...
    >>
    >>I am trying to write a timedelta meter, i.e. "it has been U years, V
    >>months, W day's, X hours, Y minutes, Z seconds since SomePoint"
    >>
    >>Here's what I have so far, I can print the current time/date but am
    >>having issues figuring out how to timedelat it...
    >>
    >>____________________________________________________
    >># dunno about this
    >>from datetime import datetime, timedelta
    >>
    >># This works, will print date/time
    >>
    >>from time import gmtime, strftime
    >>strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime())
    >>
    >>
    >># sometime
    >>myYear = "2004"
    >>myMonth = "7"
    >>myDay = "8"
    >>myHour = "6"
    >>myMinute = "21"
    >>mySecond = "13"
    >>-----------------------------------------------------
    >>
    >>--
    >>Wil
    >>my 2¢
    >>
    >>"When everything seems to be going well, you have obviously overlooked
    >>something."

    >
    >
    > Check out the datemtime module, in particular the timedelta class.
    > Hope this helps.
    >
    > http://www.python.org/doc/current/lib/module-datetime.html
    >
    > Adonis
    >
    >
    Wil Schultz, Jul 23, 2004
    #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. The Eeediot
    Replies:
    3
    Views:
    2,214
    =?Utf-8?B?UnVsaW4gSG9uZw==?=
    Dec 22, 2004
  2. Christos TZOTZIOY Georgiou
    Replies:
    3
    Views:
    685
    Christos TZOTZIOY Georgiou
    Sep 13, 2003
  3. Tim Peters
    Replies:
    0
    Views:
    518
    Tim Peters
    Sep 9, 2003
  4. josh
    Replies:
    0
    Views:
    303
  5. George2
    Replies:
    1
    Views:
    781
    Alf P. Steinbach
    Jan 31, 2008
Loading...

Share This Page