Search code examples
common-lisp

Package to parse dates in Common Lisp?


I'm writing a simple web scraper in Common Lisp (SBCL) as a learning exercise, & would like to sort by date. To do this, I'll need to parse dates in the format "MM/DD/YYYY" into universal time.

I could simply tokenise the string & pass the bits into encode-universal-time, but I figure that there must be a built-in function (or popular third-party package) for date parsing. I'd greatly appreciate someone recommending one :-)


Solution

  • This answer is very late but the local-time library is featureful and widely used. It is based on the article The long painful history of time.

    It supports :

    1. Time and date arithmetic
    2. ISO 8601 timestring formatted output and parsing
    3. Reader macros to embed timestrings directly in code
    4. Timezone handling (will read unix tzfile format)
    5. Conversion between universal and unix time epochs
    6. Julian date calculation