The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
# Astro::App::Satpass2 source file. Invoke as (e.g.)
# satpass2> source eg/quarters_vcalendar
#
# Do quarter calculations, displaying the results in vCalendar format. The
# output may be redirected to a .vcal file. The start and end dates for the
# pass calculation can be passed as arguments to the 'source' statement, and
# default to 'today noon' and '+8' respectively.  This whole thing (less the
# comments) could be wrapped up as a macro if desired.

#	CAVEAT: My ancient Palm desktop software appears not to properly
#	handle the switch between normal and daylight-saving  time
#	(a.k.a. summer time), in that predictions made before the switch
#	for events after the switch get assigned the wrong time, even
#	though the UT event time is correct in the emitted file. I have
#	not changed the event times to local time eg/flare_vcalendar
#	because the vcalendar standard specifies UT.

localize formatter

# We want to round the times to the nearest minute

formatter round_time 60

# We intend to use date(units='z') to format the event begin and end. We
# truncate the time to the previous minute.

formatter date_format %Y%m%dT%H%M00Z

# The individual pass events get concatenated to the summary, with no newline.
# The quarters() method uses the almanac template.

formatter template almanac <<'EOD'
BEGIN:VCALENDAR
[%- FOREACH item IN data %]
BEGIN:VEVENT
DTSTART:[% item.date( units = 'zulu' ) %]
SUMMARY:[% item.almanac( units = 'description' ) %]
DTEND:[% item.date( units = 'zulu' ) %]
END:VEVENT
[%- END %]
END:VCALENDAR
EOD

# Do the quarters calculation

quarters "$@"