# 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 calculation can be passed as arguments to the 'source'
# statement, and default to 'today noon' and '+30' respectively. This
# whole thing (less the comments) could be wrapped up as a macro if
# desired.
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 "$@"