Logic to iterate through output and grab the "correct" Shabbat

Leon Adato 1 year ago updated by Michael J. Radwin 1 year ago 2

NOTE: The issue below is a programming question. I'm relatively new to "real" coding (versus utility scripts with very narrow scopes), so my belief is that this is a simple case of how to build the correct looping and logic structures. It's not an issue with the API itself or my use of it. I think.
I'm building an automatically-generated list of Shabbat dates and calculating times for mincha, candles, etc based on my shul's particular shitot. I want to grab every Saturday, but I only want to grab each Saturday ONCE.

My problem is that if I set the Major holiday switch (maj) to off, I'm missing some Shabbats.

(example, 9/23 because that's shabbat chol hamoed Sukkot, not a normal Shabbat.)

BUT if I include maj=on, I get some double saturdays

(example: 12/04, which is a 'regular' Shabbat but also noted as the 7th night of Chanukah)

So I need to figure out how to programatically grab or filter the "correct" one.

Here's a sample of the API string I'm generating:


To see the current state of the code, check here:

And the code (such as it is) can be found here:


Glad you got the problem solved!

I worked through my own issue. In the end rather than print each line, I pushed each line into an associative array. Before adding a line, I check to see if it's already there AND that the tag is "parashat". If it is, I leave it. If it's not, I write (or over-write) the line. You can find the code on github:

and you can see it running here: