Forum

    • Register
    • Login
    • Search
    • Categories

    Dates...

    General Questions
    5
    41
    380
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ustk
      ustk last edited by

      00b53da02349bc224f3f858a07c29073.jpg

      I cannot help pressing F5 in the forum...
      Studio427 Audio - Audio Instruments & FX Plugins for music production. Website - Facebook

      1 Reply Last reply Reply Quote 1
      • Lindon
        Lindon @Dan Korneff last edited by

        @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.... 🙂

        HISE Development for hire.
        www.channelrobot.com

        Dan Korneff 1 Reply Last reply Reply Quote 1
        • Dan Korneff
          Dan Korneff @Lindon last edited by

          @Lindon I only skimmed the last few posts 💩

          Dan Korneff - Producer / Mixer / Audio Nerd

          1 Reply Last reply Reply Quote 0
          • Christoph Hart
            Christoph Hart last edited by

            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...

            Lindon 1 Reply Last reply Reply Quote 2
            • Lindon
              Lindon @Christoph Hart last edited by

              @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...

              HISE Development for hire.
              www.channelrobot.com

              1 Reply Last reply Reply Quote 0
              • Lindon
                Lindon @d.healey last edited by Lindon

                @d-healey said in Dates...:

                @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....

                HISE Development for hire.
                www.channelrobot.com

                Lindon 1 Reply Last reply Reply Quote 0
                • Lindon
                  Lindon @Lindon last edited by Lindon

                  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

                  HISE Development for hire.
                  www.channelrobot.com

                  ustk 1 Reply Last reply Reply Quote 0
                  • ustk
                    ustk @Lindon last edited by

                    @Lindon the push’s been made, Christoph should merge soon

                    I cannot help pressing F5 in the forum...
                    Studio427 Audio - Audio Instruments & FX Plugins for music production. Website - Facebook

                    d.healey 1 Reply Last reply Reply Quote 1
                    • d.healey
                      d.healey @ustk last edited by

                      @ustk Already has, no?

                      https://github.com/christophhart/HISE/commits/develop

                      Libre Wave - Freedom respecting instruments and effects
                      My Patreon - HISE tutorials
                      YouTube Channel - Public HISE tutorials

                      ustk 1 Reply Last reply Reply Quote 0
                      • ustk
                        ustk @d.healey last edited by

                        @d-healey Oh yes my mistake, was waiting for the others...

                        I cannot help pressing F5 in the forum...
                        Studio427 Audio - Audio Instruments & FX Plugins for music production. Website - Facebook

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post

                        20
                        Online

                        985
                        Users

                        6.6k
                        Topics

                        60.8k
                        Posts