Mailing the story:
Check the day of year, given a date
The ugliest function in my data-auditing toolkit is "chkday". It checks to see whether an ISO 8601 date (YYYY-MM-DD) and its day number are in agreement, where both are present in a data table. I tried two other ways to get the same result but the code is still ugly.