(a) if performance isn't really important, do which ever is easier to
read and get right ( = unit-test).
When you're bug fixing 6-24 months from now future-you will be happier
and thank current-you.
The 1st general rule is to defer optimization until proven it's needed.
[See: Jon Bentley, [more] Programming Pearls]

(b) if performance matters because you have large volumes of events
(compared to time waiting for them to process) , factor into a
function and implement it two ways
sub is_night_next  { ... }
sub is_night_span { ... }
and use Benchmark qw(:all); benchmarking to compare the two:
http://perldoc.perl.org/Benchmark.html
http://perltricks.com/article/40/2013/9/29/How-to-benchmark-Perl-code-for-speed/

(and also test both versions with the same unit test suite to
demonstrate equivalence! wrong algorithms can be arbitrarily sped up
...
    sub wrong { return};  # always faster
)

At least this doesn't have an edge-case at DST ...  and sunset at
Swarthmore should be either before (DEC 31) or after (JUN 30) the UTC
leap second, iirc. But there must be some lat-lon's where the leap
second is perilously close to sunset (or sunrise in East longitude),
something to consider if your code  covers multiple lat-lon's.

Reply via email to