Using Javascript to format dates

Mask:

Date masks to try:

Mask format key

Notes

It seems pretty obviousin hindsight that the better way would be to extend the Javascript date object, so that we could just call dateObj.format("dd-mmm-yyyy"). Live and learn--a task for another day.

Function List

  1. array getMonthNameArray() - returns array of month names
  2. array getMonthAbbrArray() - returns array of month abbreviations
  3. int getDaysInMonth(date object) - returns number of days in month (including 29 for Feb in leap years)
  4. bool isLeapYear(date object) - returns whether or not the date specified is in a leap year
  5. Date prevMonth(date object) - returns date object one month back
  6. Date nextMonth(date object) - returns date object one month ahead
  7. str dayFormat(d number,mask string) - returns formatted day-of-month string
  8. str monthFormat(m number,mask string) - returns formatted month string
  9. str yearFormat(y number,mask string) - returns formatted year string
  10. str dateFormat(date object,mask string) - returns formatted date string