Dates...
-
-
@Dan-Korneff said in Dates...:
@d-healey That works too, and you save 4 lines of code.
if we are interested in saving lines of code my original version is precisely 1 line.... :-)
-
@Lindon I only skimmed the last few posts
-
if we are interested in saving lines of code my original version is precisely 1 line....
But you need to ship an update in 2036 and we're all in here for the long run...
-
@Christoph-Hart said in Dates...:
if we are interested in saving lines of code my original version is precisely 1 line....
But you need to ship an update in 2036 and we're all in here for the long run...
well you have me there...
-
@Dan-Korneff Why not?
inline function isLeapYear(year) { return (0 == year % 4) && (0 != year % 100) || (0 == year % 400)); }
except when you try this it always returns true....so it doenst work.
-- oh hang on I spot a typeo in my implementation....
-
Okay so whilst we await @ustk 's push here's a fix using just HISE:
function isLeapYear(aYear) { return ((0 == aYear % 4) && (0 != aYear % 100) || (0 == aYear % 400)); } function daysFrom2000(aYear,aMonth,aDay) { reg calcYear = 2000; reg totalDays = 0; reg leap = 0; reg monthAmounts = [31,28,31,30,31,30,31,31,30,31,30,31]; if(aYear < calcYear) return -1; if(aMonth > 2 && isLeapYear(aYear)) leap = 1; totalDays = aDay + leap; for(i = 0; i< aMonth-1; i++) { totalDays = totalDays + monthAmounts[i]; }; while(calcYear < aYear) { totalDays = totalDays + 365 + isLeapYear(calcYear); calcYear++; }; return totalDays; } Console.print(daysFrom2000(2023,01,01));
Obviously just doing days not microseconds
-
@Lindon the push鈥檚 been made, Christoph should merge soon
-
@ustk Already has, no?
Commits 路 christophhart/HISE
The open source framework for sample based instruments - Commits 路 christophhart/HISE
GitHub (github.com)
-
@d-healey Oh yes my mistake, was waiting for the others...