This is usually something you search online and something pops up, but no such luck in finding something in Squirrel code so thought to pop the question in the forum before embarking on developing something from scratch / hacking something together.
Has anyone done it before and/or willing to share and/or provide helpful tips on creating a utility function that will give me the number of days between two calendar dates. I need this to work out a wakeup timer which could be anything from 1 day up to 248 days. I have it in my code that the user can enter a future date through an html form and this is compared to current date. Just wouldn’t want to be a day late / early due to leap years, miscalculating days in a calendar month etc.
It appears that using the forum search option to search through historical forum posts is rather hit and miss in pulling out relevant content. Having spent more time on it I stumbled across two useful posts… here is one of them as now I cannot find the other one again?? … working on a different computer and cannot quite recall exact search phrases… oh well
Since the Imp already uses the cloud, and requires the internet anyhow, I would create a simple PHP API on my own website to do the calculation with PHP, which is easy. The imp agent would query my script with 2 dates and the script would return the answer. PHP can also adjust to any timezone easily. I realize that doing this requires another website (outside of the cloud), but I use my website for many other Imp related things already … such as saving data in a MySQLi database. Or even turning on my Christmas lights only when the word “snow” appears in the current weather conditions on Weather Underground.
Hmmm … my website and my Imp Agent are always discussing things with each other, behind my back. I think it’s actually one of the coolest things about my Imps.
Yes using php would be handy all right and was considering that approach.
I think you can do this with date(integer) method as the table returned from date function has a unix timestamp bolted on the end. Just a pity you have to be a math genius to first calculate this integer value for your chosen date. If we were able to enter optional parameters for year, month, day etc. as we can in jscript and php, life would be so much easier.
I’m like you. I am very new to Squirrel and don’t have the experience to solve something like that without lots of research and script examples. I am in awe with the Squirrel scripting I see others do … they make it look so simple. Maybe someday I’ll be “worthy” … [sigh]