Developer's Diary
Software development, with Terry Ebdon
|
I create daily page templates, for this site, using WebDoxy's -j
option. I have another site with weekly entries. It would be nice if WebDoxy could create "week per view" template pages for that site as well. That's tricky enough to be interesting. The site has monthly, quarterly and weekly pages with cross links. It also uses ISO 8601 week numbers. Java's SimpleDateFormatter
can handle week numbers, but not quarters. The java.time.ZonedDateTime
class is aware of ISO week numbers and quarters.
The generated markdown for week 18, 2020, will start like this:
# April / May 2020, week 18 {#y2020w18}
There's the first wrinkle, some weeks are split across two months. It gets better, a week can also be split across two years:
# December 2020 / January 2021, week 53 {#y2020w53}
The new --week
option will need to generate up to a year of weekly pages, determined by the --number
option, starting at an arbitrary week, specified with --date
, and defaulting to the current week.
The following two commands will create identical pages, if run on May 26, 2020:
groovy WebDoxy.groovy --week --number 1 --date 2020-05-26 groovy.groovy --week
The first step is to determine the week number, based on the given date. I'll also need dates for first and last days of that week, i.e. the Monday and Sunday. (The ISO standard specifies Monday as the start of the week, as most people would expect.)
This is easy in Groovy, as the Date class is extended to support integer maths:
24-MAY-2020 👈 Top of page 👉 27-MAY-2020
© 2020 Terry Ebdon.
Find me coding on GitHub, networking on LinkedIn, answering questions on Stack Exchange and hanging out on twitter.