You Are Here:

Community: Developer Discussion Boards

#1 Old Date/Time - 2009-06-24, 16:21

Join Date: Mar 2006
Posts: 26
patlucas
Offline
Registered User
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
Reply With Quote

#2 Old Re: Date/Time - 2009-06-24, 16:31

Join Date: Oct 2007
Posts: 2,845
Location: Deva, Romania
bogdan.galiceanu's Avatar
bogdan.galiceanu
Online
Forum Nokia Champion
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.
Reply With Quote

#3 Old Re: Date/Time - 2009-06-24, 17:37

Join Date: Mar 2006
Posts: 26
patlucas
Offline
Registered User
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
Reply With Quote

#4 Old Re: Date/Time - 2009-06-24, 18:00

Join Date: Oct 2007
Posts: 2,845
Location: Deva, Romania
bogdan.galiceanu's Avatar
bogdan.galiceanu
Online
Forum Nokia Champion
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.
Reply With Quote

#5 Old Re: Date/Time - 2009-06-25, 00:28

Join Date: Mar 2006
Posts: 26
patlucas
Offline
Registered User
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"?
Reply With Quote

#6 Old Re: Date/Time - 2009-06-25, 09:39

Join Date: Oct 2007
Posts: 2,845
Location: Deva, Romania
bogdan.galiceanu's Avatar
bogdan.galiceanu
Online
Forum Nokia Champion
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)
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
RFileLogger Date/Time Format tsdgeos General Symbian C++ 1 2009-03-11 05:59
is it possible to acquire date/time from built in GPS? kavehmb2000 Mobile Java General 9 2009-03-10 06:13
getting the file date/time irrespective of sytem date himsymbian General Symbian C++ 9 2009-02-13 12:57
Is it possible to check App's modification date/time without AllFiles capability. jvinjam General Symbian C++ 3 2009-01-27 09:24
PC Suite date/time problem dohanin General Discussion 1 2006-01-25 12:33

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia