Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User protochip's Avatar
    Join Date
    Oct 2008
    Posts
    18
    Dear Friends,

    Can anyone tell me how to use time related events? For example; i want to run a def() in my code when time is 12.00 pm... Is it possible? Also can i make time entry as a variable defined by the user of the application? Lets say the user enter time as 01.00 am then def() will run at 01.00 am... Any example code that i can work on it and improve? Sorry that i am a beginner but a little help is welcome...

    Regards...

  2. #2
    Super Contributor Rafael T.'s Avatar
    Join Date
    Feb 2008
    Location
    Belo Horizonte, Brazil
    Posts
    744
    Quote Originally Posted by protochip View Post
    Dear Friends,

    Can anyone tell me how to use time related events? For example; i want to run a def() in my code when time is 12.00 pm... Is it possible? Also can i make time entry as a variable defined by the user of the application? Lets say the user enter time as 01.00 am then def() will run at 01.00 am... Any example code that i can work on it and improve? Sorry that i am a beginner but a little help is welcome...

    Regards...
    Hi protochip,

    Yes you can do that!

    You can try something like this:

    Code:
    import appuifw, time
    
    def read_time():
    
        current_time = time.localtime()[3]
        print current_time # This will print a number that indicates current hour
        user_time = appuifw.query(u"Insert desired time:", "number")
        # Supposing the user will enter only a hour, if you want full time with minutes, change "number" by "time"
        
        if current_time == user_time:
            my_function() # Calls the function
    
    def my_function():
        
        appuifw.note(u"Current time is now equal user time")
    
    read_time()
    Also check this article on the Wiki for learning how to get time and date



    Hope it helps,

    Rafael.

  3. #3
    Registered User protochip's Avatar
    Join Date
    Oct 2008
    Posts
    18
    Dear Rafael T,

    This will help me so much... Thank you... Now i can work on the code and learn new things to improve my code skills...

    Regards...

  4. #4
    Registered User protochip's Avatar
    Join Date
    Oct 2008
    Posts
    18
    Dear friends,

    i worked on that code and i am stucked here... When i try to save user_time to a file it wont match with the current_time i mean the format...

    here is my code:

    Code:
    import appuifw, time, e32
    
    autime = "c:\\system\\autime.ini"
    
    def uptime():
        f = open(autime, 'r')
        tim = f.read()
        f.close()
        return tim
    
    def setautoupdate():
        user_time = appuifw.query(u"ENTER UPDATE TIME:", "time")
        f = open(autime, 'w')
        f.write(str(user_time))
        f.close()
        appuifw.note(u"UPDATE TIME SAVED !", 'info')
    
    def autoupdateon():
        timer=timer = e32.Ao_timer()
        tm=uptime()
        autime=1
        current_time = time.localtime()[3:5]
        while autime:
            if current_time == tm:
                appuifw.note(u"UPDATING DATA...", 'info')
            else:
                pass
            timer.after(0)
    
    .....
    .......
    When i open the saved file i see some numbers like 84960.0 not a time like 23.45... So how can i match the current_time and saved user_time so my loop can work correct?

    Regards...
    Last edited by protochip; 2008-11-13 at 23:19.

Similar Threads

  1. some question about the time represent in symbian
    By team-vx in forum Symbian C++
    Replies: 1
    Last Post: 2007-08-30, 14:25
  2. Bizarre calendar/time zone change handling in Nokia 9500
    By noetus in forum General Development Questions
    Replies: 0
    Last Post: 2005-09-19, 19:27
  3. 3510i Related Question
    By MaCe in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2004-01-14, 13:55
  4. Question related to Message Type ?
    By naoriya in forum General Messaging
    Replies: 2
    Last Post: 1970-01-01, 02:00
  5. Clarification: Question related to Message Type ?
    By naoriya in forum General Messaging
    Replies: 1
    Last Post: 1970-01-01, 02:00

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved