Error 403 from Google Calendar? Upgrade to the new Google Calendar support. See here for details. close
Welcome, Guest
Please Login or Register.    Lost Password?

API to monitor the date change of the system
(1 viewing) (1) Guest
Go to bottomPage: 12
TOPIC: API to monitor the date change of the system
#14558
API to monitor the date change of the system 3 Years, 9 Months ago  
I am writing a lua script to add an event for the current date. Because the event changes day by day so I need to know the change of the system date and change the event. I found that rainlendar can change the display as soon as the system date changes, so I want to know whether there is a API to handle this issue? I read the API references but found nothing. Maybe adding a new event to the Rainlendar_SetEventHandler function is a good idea.

By the way, I set a timer to change the event every 10 minutes.
atb
Fresh Boarder
Posts: 13
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#14565
Re:API to monitor the date change of the system 3 Years, 9 Months ago  
With Lua, you can use the os.date to get the current day, and then store the date in a global variable. If comparing the date changes you can remove the previous event and create a new one. Is that what you need?

Code:

currentDate = os.date("%d/%m/%Y")
_, _, day, month, year = currentDate:find("(.*)/(.*)/(.*)")



I don't understand... the event changes every 10 minutes every day???
Jorge_Luis
Platinum Boarder
Posts: 795
graphgraph
User Offline Click here to see the profile of this user
Gender: Male My Rainlendar Skins Location: Argentina Birthday: 03/15
The administrator has disabled public write access.
 
#14567
Re:API to monitor the date change of the system 3 Years, 9 Months ago  
Well, you are right, but the problem is that the script doesn't run all the time. So I have to set a timer to run the script every 10 minutes to see whether the system date is changed or to renew the event according to the current os.date value.
atb
Fresh Boarder
Posts: 13
graphgraph
User Offline Click here to see the profile of this user
Last Edit: 2011/02/23 10:30 By atb.
The administrator has disabled public write access.
 
#14578
Re:API to monitor the date change of the system 3 Years, 9 Months ago  
The timer is quite light weight so I don't think it will add too much load to your system if you check the date every second. Alternatively you could calculate the time to midnight and create a single shot timer that triggers on that time. It might also be possible to use the redraw event for this. I'm not sure though if you should be creating new events while the windows are drawn but you can create a very short timer callback which adds the event immediately after drawing is done (if the day has changed that is).
Rainy
Moderator
Posts: 6052
graph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#14588
Re:API to monitor the date change of the system 3 Years, 9 Months ago  
I think the best way is to set a timer to check the date at present. I noticed that the calenders could be updated immediately when the date was changed at midnight or mannually. So I am curious about how rainlendar detects the date changes. Is there something like a timer to check the date every second?
atb
Fresh Boarder
Posts: 13
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#14600
Re:API to monitor the date change of the system 3 Years, 9 Months ago  
Yes, Rainlendar has a timer which checks the date once per second.
Rainy
Moderator
Posts: 6052
graph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
Go to topPage: 12
get the latest posts directly to your desktop