Given a list of activities and their start time/date, output an ASCII-art calendar showing the activities on the appropriate days. All activities are guaranteed to be in the same month, no two activities will be on the same day, and all activities are guaranteed to fit within the calendar box.
The calendar has the date in the upper-left corner of each box, the boxes are 9 spaces wide by 5 spaces tall, surrounded by -
and |
. The two-letter abbreviation for the day of the week is centered above the first row, and the weeks start with Sunday.
For example, given the following activities:
10/5/2018 - 9:00am - Sandbox calendar challenge
10/9/2018 - 9:00am - Post challenge to main
10/10/2018 - 10:00am - Profit
10/31/2018 - 7:30pm - Halloween party
Output this corresponding calendar:
Su Mo Tu We Th Fr Sa
-----------------------------------------------------------------------
| |1 |2 |3 |4 |5 |6 |
| | | | | |9:00am | |
| | | | | |Sandbox | |
| | | | | |calendar | |
| | | | | |challenge| |
-----------------------------------------------------------------------
|7 |8 |9 |10 |11 |12 |13 |
| | |9:00am |10:00am | | | |
| | |Post |Profit | | | |
| | |challenge| | | | |
| | |to main | | | | |
-----------------------------------------------------------------------
|14 |15 |16 |17 |18 |19 |20 |
| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | |
-----------------------------------------------------------------------
|21 |22 |23 |24 |25 |26 |27 |
| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | |
-----------------------------------------------------------------------
|28 |29 |30 |31 | | | |
| | | |7:30pm | | | |
| | | |Halloween| | | |
| | | |party | | | |
| | | | | | | |
-----------------------------------------------------------------------
Clarifications
- The schedule words (matching [A-Za-z]+) will delimited by a single space between them (as in the example).
- Splitting the text on word boundaries is sufficient. No need for hyphenating words.
- If February starts on a Sunday in a non-leap-year, you only will have four calendar rows.
- If a 31-day month (e.g., August) starts late in the week, you may have to output six calendar rows.
I/O and Rules
- Your code must handle dates at least between
0001-01-01
and9999-12-31
in the Gregorian calendar, including leap years as appropriate. For example, if given input2016-02-13 9:00am Test
, the output calendar should have February 29. - Input date format can be in any desired format. ISO 8601, a
datetime
object, a particularly-formatted string, etc. Input parsing is not the interesting part of this challenge. - Input and output can be by any convenient method.
- Leading/trailing newlines or other whitespace are optional, provided that the characters line up appropriately.
- Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
- Output can be to the console, returned as a list of strings, returned as a single string, etc.
- Standard loopholes are forbidden.
- This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.
1752-09-02 - 09:00am - Wife's Birthday Tomorrow (14th!)
\$\endgroup\$