Read the statement by Michael Teeuw here.
[Coding] update time from every 1 second to scheduled time
-
updateLunarCal: function() { let MS_in_day = 24*60*60*1000; let now = moment(); let MS_til_midnight = MS_in_day - (now.diff(now.clone().startOf('day'), 'milliseconds')); // start a one time timer to end of day setTimeout((selft) =>{ //in one time timer(at 00:00:00), start interval for next start of day setInterval((selfi)=>{ // fetch data, once per day at 00:00:00 selfi.fetchIt(selfi) // use 'this' pointer passed to the interval routine },MS_in_day, selft) // pass 'this' pointer passed to us // fetch on the 1st start of day, one time selft.fecthIt(selft) }, MS_til_midnight, this ); // pass 'this' to the timer routine // fetch data now, 1st time this.fetchIt(this); },
Thank you so much for your reply. I got error while running above function. There may be some syntax error. But I can’t fix it. Please help me again. Thanks
-
It seems OK now. I will test it on tonight and will share it to all later. Thank you so much.
-
@kent79 error, yeh, sorry, forgot to change the self?.fetchIt() to use the right self pointer… fixed now
-
@sdetweil said in [Coding] update time from every 1 second to scheduled time:
@kent79 error, yeh, sorry, forgot to change the self?.fetchIt() to use the right self pointer… fixed now
Would you like to tell me which line need to update since I don’t know how to do? I have tested the above code, no syntax error, but no working while on 00:00. Thanks
-
@kent79 I updated my prior post
-
Sorry, it still not working. I would like to share the module as below. Would you please help to fix it? Many thanks.
-
@kent79 here you go
use this repogit clone https://github.com/sdetweil/MMM-Lunar.git
then u can git init to wipe out my repo
the BIG cause was that your start routine
called
this.updateLunarCal();
not
this.updateLunarDate();start also doesn’t need to call fetchIt as the updateLunarDate does that after setting up the timer
I cleaned up the rest…
you can test by setting the ‘end time’ in ms…
hour and minute and then see it fire the setTimeout handler
see comment in the code -
Thank you for your all effort. My dream is coming true soon.
I have tested. No Luck. Don’t know is it coding program or my testing method wrong.
I am using windows brower to connect MM server. Then, changing windows clock to 23:59. After 00:00, there is no any changing of Lunar date.
-
@kent79 said in [Coding] update time from every 1 second to scheduled time:
I am using windows brower to connect MM server. Then, changing windows clock to 23:59.
you have to set the clock BEFORE opening the MM page… it doesn’t reset when the clock changes…
the code only sets up ONCE when loaded, so the clock has to be set first…
learn to use the developers window, ctrl-shift-i , sources tab,
you can step thru the code
ohhhhhh
and I gave it set to trigger BEFORE midnight… see the code, comment out and restore the 24×60… so you could test without having to reset the clock
-
I have tested again. But it is still not up to date while past 0:00 :(