×

Discussion Board

Results 1 to 6 of 6

Thread: Date/Time

  1. #1
    Regular Contributor
    Join Date
    Mar 2006
    Posts
    55

    Date/Time

    Hi

    I am new to Python.
    I have v1.4.5 installed on my handset and I wish to do some data/time calculations.
    Is there an obhect I can use to store a data/time and add or substract a number of days to/from it?

    REgards

    Patrick

  2. #2
    Nokia Developer Moderator
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: Date/Time

    Hi,

    Well, you should check out the time module. It has all sorts of functions that can help. The documentation is here.

    If you're willing to use PyS60 1.9.5 or later you can also use the datetime module.

  3. #3
    Regular Contributor
    Join Date
    Mar 2006
    Posts
    55

    Re: Date/Time

    Hi

    TYhanks for your reply. What if I was to do the following, would I get todays date + 10 days?

    time.gettime() + 10

    How about having a tine representing 25/12/2009, would the following work?

    time.mktime(time.struct_time(tm_year=2009, tm_mon=12, tm_mday=25, tm_hour=0, tm_min=0, tm_sec=0, tm_isdst=-1))

    Regards

    Patrick

  4. #4
    Nokia Developer Moderator
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: Date/Time

    Quote Originally Posted by patlucas View Post
    What if I was to do the following, would I get todays date + 10 days?

    time.gettime() + 10
    There is no gettime function in the time module. You could do something like this:
    Code:
    time.time() + 10*86400
    time.time() returns the current time in seconds since January 1st, 1970. So you just add 10 times the number of seconds in a day.

    Quote Originally Posted by patlucas View Post
    How about having a tine representing 25/12/2009, would the following work?

    time.mktime(time.struct_time(tm_year=2009, tm_mon=12, tm_mday=25, tm_hour=0, tm_min=0, tm_sec=0, tm_isdst=-1))
    Have you tried it? It's always better to try something and see for yourself if it works If it doesn't, post your problem here and we'll try to help.

  5. #5
    Regular Contributor
    Join Date
    Mar 2006
    Posts
    55

    Re: Date/Time

    I have tried constructing a struct_time "object" called base in the following way.

    base.tm_year = 2009
    base.tm_mon = 3
    base.tm_mday = 1
    base.tm_hour = 0
    base.tm_min = 0
    base.tm_sec = 0
    base.tm_isdst = -1

    When I try to run this, the interpreter tells me that "base" is undefined. How do I tell the interpreter that "base" is a struct_time "object"?

  6. #6
    Nokia Developer Moderator
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: Date/Time

    struct_time the type of the tuples returned by functions like localtime(). Anyway, you can create s struct_time object from a sequence by calling the struct_time function on that sequence:
    Code:
    example = [2009, 6, 25, 10, 30, 43, 3, 176, 1]
    base = time.struct_time(example)

Similar Threads

  1. RFileLogger Date/Time Format
    By tsdgeos in forum Symbian C++
    Replies: 1
    Last Post: 2009-03-11, 04:59
  2. is it possible to acquire date/time from built in GPS?
    By kavehmb2000 in forum Mobile Java General
    Replies: 9
    Last Post: 2009-03-10, 05:13
  3. getting the file date/time irrespective of sytem date
    By himsymbian in forum Symbian C++
    Replies: 9
    Last Post: 2009-02-13, 11:57
  4. Replies: 3
    Last Post: 2009-01-27, 08:24
  5. PC Suite date/time problem
    By dohanin in forum General Development Questions
    Replies: 1
    Last Post: 2006-01-25, 11:33

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •