iso-8601-date

2019-01-07

EclecticSE ISO 8601 Date Representation Routines

David K. Trudgett

Miscellaneous date routines based around the ISO 8601 string representation.

Function List

  • d/m/y->iso-8601-date

Convert a date string in d/m/y format into ISO 8601 string format. Returns NIL for invalid dates. Does not check leap year for the number of days in February (assumes 29 February is correct).

  • date-add

Add a given number of days to a date.

  • date-diff

Return the number of days between two dates.

  • date-portion

Return the date portion of an ISO 8601 date/time string. Assumes that the date string contains hyphen separators, and is therefore exactly ten characters long.

  • day-of-week

For a given date, return the day of the week on which it falls.

  • extract-day

For a given date, return the integer value of the day of the month.

  • extract-month

For a given date, return the integer value of the month of the year.

  • extract-year

For a given date, return the integer value of the year.

  • human-date

Strip the T from an ISO 8601 date, and remove decimal portion of the seconds value, if any.

  • iso-8601-date-now

Return today's date in ISO 8601 string format.

  • iso-8601-date-time-now

Return the current date and time as an ISO 8601 date and time string.

  • iso-8601-time-now

Return the current time in ISO 8601 string format.

  • last-month

Return the ISO 8601 year/month string for the month previous to the current month. Example: if current month is May 2020, return "2020-04".

  • make-iso-8601-date

Given numerical values for the year, month and day of the month, return the corresponding ISO 8601 date string.

  • num-day-of-week

For a given ISO 8601 date string, return the numerical day of the week on which it falls, where 1 = Sunday, and so on. Note: Monday is not the first day of the week.

License

LLGPL

Author
David K. Trudgett
License
LLGPL