<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[[Coding] update time from every 1 second to scheduled time]]></title><description><![CDATA[<pre><code>updateLunarCal: function() {
		var url1 =  ..... ;
		var self = this;
		var nextLoad = this.config.updateInterval;
		
		fetch(url1)
			.then((resp) =&gt; resp.json())
			.then(function(data) {
				
				self.lunar = data.LunarDate ;				
				self.updateDom();
			})		

			.catch(function(error) {
				// If there is any error you will catch them here
			});		
			
		setTimeout(function() {
			self.updateLunarCal();
		}, 1000);

	},

</code></pre>
<p dir="auto">I would like to change as above code of update time from every 1 second to scheduled time. For example: Everyday on 0:00. Please teach me. Thank you</p>
]]></description><link>https://forum.magicmirror.builders/topic/18733/coding-update-time-from-every-1-second-to-scheduled-time</link><generator>RSS for Node</generator><lastBuildDate>Sun, 07 Jun 2026 10:33:24 GMT</lastBuildDate><atom:link href="https://forum.magicmirror.builders/topic/18733.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 12 May 2024 23:55:55 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [Coding] update time from every 1 second to scheduled time on Tue, 14 May 2024 11:18:38 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kent79" aria-label="Profile: kent79">@<bdi>kent79</bdi></a> correct . I told you that I had changed the constant to test trigger<br />
and that you had to change it back</p>
]]></description><link>https://forum.magicmirror.builders/post/117751</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/117751</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Tue, 14 May 2024 11:18:38 GMT</pubDate></item><item><title><![CDATA[Reply to [Coding] update time from every 1 second to scheduled time on Tue, 14 May 2024 10:58:15 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a></p>
<p dir="auto"><img src="/assets/uploads/files/1715684147564-1.png" alt="1.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Combined the lunar script to default clock module. It looks great. Thank you again for your great help. :)</p>
]]></description><link>https://forum.magicmirror.builders/post/117750</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/117750</guid><dc:creator><![CDATA[kent79]]></dc:creator><pubDate>Tue, 14 May 2024 10:58:15 GMT</pubDate></item><item><title><![CDATA[Reply to [Coding] update time from every 1 second to scheduled time on Tue, 14 May 2024 11:23:32 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a></p>
<p dir="auto">I find out line 41 coding is wrong, the correct value is “MS_in_day = 1000<em>60</em>60*24”. I have tested and work fine now. Thanks.</p>
<p dir="auto">Orginal:<br />
let MS_in_day =</p>
<pre><code class="language-js">20*60*60*1000+8*60*1000  //24*60*60*1000;
</code></pre>
<p dir="auto">New:</p>
<pre><code class="language-js">let MS_in_day = 1000*60*60*24;
</code></pre>
]]></description><link>https://forum.magicmirror.builders/post/117745</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/117745</guid><dc:creator><![CDATA[kent79]]></dc:creator><pubDate>Tue, 14 May 2024 11:23:32 GMT</pubDate></item><item><title><![CDATA[Reply to [Coding] update time from every 1 second to scheduled time on Tue, 14 May 2024 03:17:04 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kent79" aria-label="Profile: kent79">@<bdi>kent79</bdi></a> if you edit the  constant  so it is 5 minutes from now, does it trigger?</p>
<p dir="auto">the fetch will still get today’s time</p>
]]></description><link>https://forum.magicmirror.builders/post/117743</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/117743</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Tue, 14 May 2024 03:17:04 GMT</pubDate></item><item><title><![CDATA[Reply to [Coding] update time from every 1 second to scheduled time on Tue, 14 May 2024 02:57:58 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a></p>
<p dir="auto">of course. I have still no idea</p>
]]></description><link>https://forum.magicmirror.builders/post/117742</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/117742</guid><dc:creator><![CDATA[kent79]]></dc:creator><pubDate>Tue, 14 May 2024 02:57:58 GMT</pubDate></item><item><title><![CDATA[Reply to [Coding] update time from every 1 second to scheduled time on Tue, 14 May 2024 02:49:01 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kent79" aria-label="Profile: kent79">@<bdi>kent79</bdi></a> did u edit the code and change the constant back?</p>
]]></description><link>https://forum.magicmirror.builders/post/117741</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/117741</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Tue, 14 May 2024 02:49:01 GMT</pubDate></item><item><title><![CDATA[Reply to [Coding] update time from every 1 second to scheduled time on Tue, 14 May 2024 02:31:06 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a></p>
<p dir="auto">I have tested again. But it is still not up to date while past 0:00 :(</p>
]]></description><link>https://forum.magicmirror.builders/post/117740</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/117740</guid><dc:creator><![CDATA[kent79]]></dc:creator><pubDate>Tue, 14 May 2024 02:31:06 GMT</pubDate></item><item><title><![CDATA[Reply to [Coding] update time from every 1 second to scheduled time on Tue, 14 May 2024 02:30:35 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kent79" aria-label="Profile: kent79">@<bdi>kent79</bdi></a> said in <a href="/post/117738">[Coding] update time from every 1 second to scheduled time</a>:</p>
<blockquote>
<p dir="auto">I am using windows brower to connect MM server. Then, changing windows clock to 23:59.</p>
</blockquote>
<p dir="auto">you have to set the clock BEFORE opening the MM page… it doesn’t reset when the clock changes…</p>
<p dir="auto">the code only sets up ONCE when loaded, so the clock has to be set first…</p>
<p dir="auto">learn to use the developers window, ctrl-shift-i , sources tab,</p>
<p dir="auto">you can step thru the code</p>
<p dir="auto">ohhhhhh</p>
<p dir="auto">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</p>
]]></description><link>https://forum.magicmirror.builders/post/117739</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/117739</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Tue, 14 May 2024 02:30:35 GMT</pubDate></item><item><title><![CDATA[Reply to [Coding] update time from every 1 second to scheduled time on Tue, 14 May 2024 01:33:31 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a></p>
<p dir="auto">Thank you for your all effort. My dream is coming true soon.</p>
<p dir="auto">I have tested. No Luck. Don’t know is it coding program or my testing method wrong.</p>
<p dir="auto">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.</p>
]]></description><link>https://forum.magicmirror.builders/post/117738</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/117738</guid><dc:creator><![CDATA[kent79]]></dc:creator><pubDate>Tue, 14 May 2024 01:33:31 GMT</pubDate></item><item><title><![CDATA[Reply to [Coding] update time from every 1 second to scheduled time on Tue, 14 May 2024 01:14:39 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kent79" aria-label="Profile: kent79">@<bdi>kent79</bdi></a> here you go<br />
use this repo</p>
<p dir="auto">git clone <a href="https://github.com/sdetweil/MMM-Lunar.git" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/sdetweil/MMM-Lunar.git</a></p>
<p dir="auto">then u can git init to wipe out my repo</p>
<p dir="auto">the BIG cause was that your start routine<br />
called<br />
this.updateLunarCal();<br />
not<br />
this.updateLunarDate();</p>
<p dir="auto">start also doesn’t need to call fetchIt as the updateLunarDate does that after setting up the timer</p>
<p dir="auto">I cleaned up the rest…</p>
<p dir="auto">you can test by setting the ‘end time’ in ms…<br />
hour and minute and then see it fire the setTimeout handler<br />
see comment in the code</p>
]]></description><link>https://forum.magicmirror.builders/post/117737</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/117737</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Tue, 14 May 2024 01:14:39 GMT</pubDate></item><item><title><![CDATA[Reply to [Coding] update time from every 1 second to scheduled time on Tue, 14 May 2024 00:03:44 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a></p>
<p dir="auto">Sorry, it still not working. I would like to share the module as below. Would you please help to fix it? Many thanks.</p>
<p dir="auto"><a href="https://www.dropbox.com/scl/fi/qxcbjuibaaaz7ojwr7ucs/MMM-Lunar.zip?rlkey=4zeyqxpp4ibchq2znb5mwpvjr&amp;dl=0" target="_blank" rel="noopener noreferrer nofollow ugc">https://www.dropbox.com/scl/fi/qxcbjuibaaaz7ojwr7ucs/MMM-Lunar.zip?rlkey=4zeyqxpp4ibchq2znb5mwpvjr&amp;dl=0</a></p>
]]></description><link>https://forum.magicmirror.builders/post/117736</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/117736</guid><dc:creator><![CDATA[kent79]]></dc:creator><pubDate>Tue, 14 May 2024 00:03:44 GMT</pubDate></item><item><title><![CDATA[Reply to [Coding] update time from every 1 second to scheduled time on Mon, 13 May 2024 23:19:49 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kent79" aria-label="Profile: kent79">@<bdi>kent79</bdi></a> I updated my prior post</p>
]]></description><link>https://forum.magicmirror.builders/post/117735</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/117735</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Mon, 13 May 2024 23:19:49 GMT</pubDate></item><item><title><![CDATA[Reply to [Coding] update time from every 1 second to scheduled time on Mon, 13 May 2024 22:57:49 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a> said in <a href="/post/117729">[Coding] update time from every 1 second to scheduled time</a>:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kent79" aria-label="Profile: kent79">@<bdi>kent79</bdi></a> error, yeh, sorry, forgot to change the self?.fetchIt() to use the right self pointer… fixed now</p>
</blockquote>
<p dir="auto">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</p>
]]></description><link>https://forum.magicmirror.builders/post/117734</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/117734</guid><dc:creator><![CDATA[kent79]]></dc:creator><pubDate>Mon, 13 May 2024 22:57:49 GMT</pubDate></item><item><title><![CDATA[Reply to [Coding] update time from every 1 second to scheduled time on Mon, 13 May 2024 17:13:24 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kent79" aria-label="Profile: kent79">@<bdi>kent79</bdi></a> error, yeh, sorry, forgot to change the self?.fetchIt() to use the right self pointer… fixed now</p>
]]></description><link>https://forum.magicmirror.builders/post/117729</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/117729</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Mon, 13 May 2024 17:13:24 GMT</pubDate></item><item><title><![CDATA[Reply to [Coding] update time from every 1 second to scheduled time on Mon, 13 May 2024 14:02:44 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a></p>
<p dir="auto">It seems OK now. I will test it on tonight and will share it to all later. Thank you so much.</p>
]]></description><link>https://forum.magicmirror.builders/post/117727</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/117727</guid><dc:creator><![CDATA[kent79]]></dc:creator><pubDate>Mon, 13 May 2024 14:02:44 GMT</pubDate></item><item><title><![CDATA[Reply to [Coding] update time from every 1 second to scheduled time on Mon, 13 May 2024 17:03:10 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a></p>
<pre><code>	 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) =&gt;{
			
			//in one time timer(at  00:00:00), start interval for next start of day
			setInterval((selfi)=&gt;{
				// 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);
	},
</code></pre>
<p dir="auto">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</p>
]]></description><link>https://forum.magicmirror.builders/post/117726</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/117726</guid><dc:creator><![CDATA[kent79]]></dc:creator><pubDate>Mon, 13 May 2024 17:03:10 GMT</pubDate></item><item><title><![CDATA[Reply to [Coding] update time from every 1 second to scheduled time on Mon, 13 May 2024 12:48:19 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kent79" aria-label="Profile: kent79">@<bdi>kent79</bdi></a> well, it will work, BUT you make a check every 100 ms… so LOTS of wasted work… let the system work for you</p>
<pre><code class="language-js">fetchIt: function(self){
		var url1 = "https://abc ....";		
		
		fetch(url1)
			.then((resp) =&gt; resp.json())
			.then(function(data) {
				// Here you get the data to modify as you please
				self.lunar = data.LunarDate;							
				self.updateDom();
			})

			.catch(function(error) {
				// If there is any error you will catch them here
			});	
},

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) =&gt;{
			
			//in one time timer(at  00:00:00), start interval for next start of day
			setInterval((selfi)=&gt;{
				// fetch data, once per day at 00:00:00
				self.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
			self.fecthIt(selft)

		}, MS_til_midnight,
		   this );  // pass 'this' to the timer routine

		// fetch data now, 1st time
		this.fetchIt(this);
}		
</code></pre>
]]></description><link>https://forum.magicmirror.builders/post/117724</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/117724</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Mon, 13 May 2024 12:48:19 GMT</pubDate></item><item><title><![CDATA[Reply to [Coding] update time from every 1 second to scheduled time on Mon, 13 May 2024 05:55:33 GMT]]></title><description><![CDATA[<pre><code>updateLunarCal: function() {

		var url1 = "https://abc ....";
		var self = this;	
		
		fetch(url1)
			.then((resp) =&gt; resp.json())
			.then(function(data) {
				// Here you get the data to modify as you please
				self.lunar = data.LunarDate;							
				self.updateDom();
			})

			.catch(function(error) {
				// If there is any error you will catch them here
			});		
			
		setTimeout(function() {

			if (moment().hours() === 0 &amp;&amp; moment().minutes() === 0 &amp;&amp; moment().second() === 0) {

				self.updateLunarCal();

			}

			else{
				
			}
		}, 100);
</code></pre>
<p dir="auto">I have revised as above code. Is it achieve my goal?</p>
]]></description><link>https://forum.magicmirror.builders/post/117723</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/117723</guid><dc:creator><![CDATA[kent79]]></dc:creator><pubDate>Mon, 13 May 2024 05:55:33 GMT</pubDate></item><item><title><![CDATA[Reply to [Coding] update time from every 1 second to scheduled time on Mon, 13 May 2024 02:19:33 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a></p>
<p dir="auto">May be I explain it clearly.</p>
<p dir="auto">I am developing a lunar calender module. As my above coding, it will connect to json server to get the lunar information ervery 1 second.</p>
<p dir="auto">I would like to change it to connect server once on Everyday 00:00.</p>
<p dir="auto">Since I am a beginner of coding, I don’t know how to do edit it. Please teach me. Thanks</p>
]]></description><link>https://forum.magicmirror.builders/post/117716</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/117716</guid><dc:creator><![CDATA[kent79]]></dc:creator><pubDate>Mon, 13 May 2024 02:19:33 GMT</pubDate></item><item><title><![CDATA[Reply to [Coding] update time from every 1 second to scheduled time on Mon, 13 May 2024 02:08:43 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/kent79" aria-label="Profile: kent79">@<bdi>kent79</bdi></a> sadly there is no magic here… just grunt work…</p>
<p dir="auto">you have to calculate the ms til 0:0:0</p>
<p dir="auto">you can use the moment library (yes I know other folks its not the new library)</p>
<pre><code class="language-js">// Your moment
var now = moment();   // now

// Your moment at midnight
var Midnight = now.clone().startOf('day');  // 00:00:00 today earlier

// Difference in milliseconds
var milliseconds_passed_already = now.diff(Midnight, 'milliseconds'); // since 00:00:00
then subtract  
var milliseconds_til_midnight_tonight = (24*60*60*1000)-milliseconds_passed_already
</code></pre>
]]></description><link>https://forum.magicmirror.builders/post/117715</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/117715</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Mon, 13 May 2024 02:08:43 GMT</pubDate></item></channel></rss>