Offset for the sunrise and sunset in macro

e:cue Forum Foren English Discussion Forums e:script Macro Language (E) Offset for the sunrise and sunset in macro

Ansicht von 6 Antwort-Themen
  • Autor
    Beiträge
    • #219119
      Alex Fomin
      Teilnehmer

      Hello everyone,

      Does anyone know the solution?

      How can I apply an offset : +15′ for the sunrise and -30′ for the sunset in macro?

      Sincerely yours,
      Alex.

    • #226572
      bkruse
      Teilnehmer

      Hi,

      if you call the macro via a Trigger Rule, then you can simply put the offset into the Trigger Rule itself.

      If you call the macro repeatedly and check for the astro event yourself, you use NiceTime() command for it.
      With NiceTime() you can get todays astro times and also the current time. You need to compare it manually then.
      See also escript help for NiceTime()

      Does that help?
      If not, please specify your question in more details.

      Bests, Björn

    • #226573
      Alex Fomin
      Teilnehmer

      Hello Bjorn,
      I am using macro only.
      Yes, I can get todays astro times and also the current time using NiceTime().

      But it`s not clear for me how can I get for example 30 minutes before sunset.

      Ideally, I would like to use the construction:

      if (IsAfter(surise+15minutes) && IsBefore(suset-30minutes))

      Sincerely yours,
      Alex.

    • #226574
      bkruse
      Teilnehmer

      Hi,

      IsAfter() and IsBefore() require the hour, minute and second to be entered separately.
      Use TimeAdd() command to add or substract your offset.

      Then you’re pretty close to your mentioned if-statement.

      Hope that helps,
      Björn

    • #226575
      Alex Fomin
      Teilnehmer

      As I understand it,
      TimeAdd() command requires the hour, minute and second to be entered separately too.

      Using TimeAdd() for “surise+15minutes” is not clear.

      Ok. Another way:

      string Sunrise; // It works using NiceTime
      string Offset; // It works using MilliSecondsToTimeStr

      Show me the way please, how I can do: “Sunrise+Offset” ???

    • #226576
      bkruse
      Teilnehmer

      Hi,

      adding or other math operations only work on int (integer variables), not on string.

      It can be done like this:


      // astroTimeWithOffset script comment
      int sunriseH = val(NiceTime(“$H1”));
      int sunriseM = val(NiceTime(“$M1”));
      int sunsetH = val(NiceTime(“$H3”));
      int sunsetM = val(NiceTime(“$M3”));
      int currentH = val(NiceTime(“%H”));
      int currentM = val(NiceTime(“%M”));
      int sec = 0;

      // add 15 min to sunrise
      int add15 = 15*60;
      TimeAdd(sunriseH, sunriseM, sec, add15);

      //substract 30 min from sunset
      int subs30 = -30*60;
      TimeAdd(sunsetH, sunsetM, sec, subs30);

      if (IsAfter(sunriseH, sunriseM, 0) && IsBefore(sunsetH, sunsetM, 0))
      {
      printf(“condition met! %d %dn”, add15, subs30);
      }

      Hope that helps,
      Björn

    • #226578
      Alex Fomin
      Teilnehmer

      Thank you so much Björn!
      It works very well!!!

      I tried make the same, but your macro is more better.

      Sincerely yours,
      Alex

Ansicht von 6 Antwort-Themen
  • Du musst angemeldet sein, um auf dieses Thema antworten zu können.