+/**
+ * @brief Output a calendar for the given month, year.
+ *
+ * If $links are provided (array), e.g. $links[12] => 'http://mylink' ,
+ * date 12 will be linked appropriately. Today's date is also noted by
+ * altering td class.
+ * Months count from 1.
+ *
+ * @param int $y Year
+ * @param int $m Month
+ * @param array $links (default null)
+ * @param string $class
+ *
+ * @return string
+ *
+ * @todo Provide (prev,next) links, define class variations for different size calendars
+ */
+function cal($y = 0, $m = 0, $links = null, $class = '')
+{
+ // month table - start at 1 to match human usage.
+ $mtab = [' ',
+ 'January', 'February', 'March',
+ 'April' , 'May' , 'June',
+ 'July' , 'August' , 'September',
+ 'October', 'November', 'December'
+ ];
+
+ $thisyear = datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y');
+ $thismonth = datetime_convert('UTC', date_default_timezone_get(), 'now', 'm');
+ if (!$y) {
+ $y = $thisyear;
+ }