The trivial-rfc-1123 Reference Manual

Next: , Previous: , Up: (dir)   [Contents][Index]

The trivial-rfc-1123 Reference Manual

This is the trivial-rfc-1123 Reference Manual, generated automatically by Declt version 4.0 beta 2 "William Riker" on Mon Aug 15 06:04:19 2022 GMT+0.

Table of Contents


1 Introduction

TRIVIAL-RFC-1123

Parses and prints dates in RFC-1123 format. Like this:

CL-USER> (ql:quickload :trivial-rfc-1123)
CL-USER> (t1123:parse-date "Fri, 16 Jul 2010 02:33:50 -0500") ;note 't1132:' abbrev.
3488254430
CL-USER> (t1123:as-rfc-1123 3488254430); default tz is 0, or GMT
"Fri, 16-Jul-2010 07:33:50 GMT"

CL-USER> (t1123:as-rfc-1123 3488254430 :timezone 5); 'cause lisp TZ is backwards
"Fri, 16-Jul-2010 02:33:50 -0500"

CL-USER> (t1123:as-rfc-1123 (get-universal-time) :timezone nil); use current tz!
...


(parse-date string)

Return: universal time for the string.

date-parse-error condition will be raised in case of problems.

(as-rfc-1123 universal-time &key (stream nil) (timezone 0)

Stream:

Timezone:

Return: string if stream is nil, nil otherwise.

License

Parts are subject to "Edi Weitz" license, and the entire surrounding project, a similar BSD 3-clause license. The lowdown: credit copyright ownership to Dr. Edward Weitz and Stacksmith, pack licenses and disclaimers with your code and distributables, and do not use the authors' names without permission for any unreasonable purpose.

History

The code started out in drakma and was shoehorned to be a standalone library for applications requiring minimal date parsing and printing.

According to Drakma authors, the following formats will be parsed:

    Wed, 06-Feb-2008 21:01:38 GMT
    Wed, 06-Feb-08 21:01:38 GMT
    Tue Feb 13 08:00:00 2007 GMT
    Wednesday, 07-February-2027 08:55:23 GMT
    Wed, 07-02-2017 10:34:45 GMT

Note: Drakma is not clear on this, but if a timezone offset is specified, it is always considered to be from GMT. It will accept "PST-02:00", but the result is same as "GMT-02:00", or plain "-02:00".

The following was added to the drakma code, based on empirical studies of NNTP dates:

    Fri, 07-02-2017 10:34:45 +0800   numeric timezone is ok - 4 digits HHMM
    Fri, 07-02-2017 10:34:45 +08:00  colon is ok HH:MM
    07-02-2017 10:34:45 GMT          omitting day is ok
	WEd, 06-Feb-08 21:01:38 GmT      no longer case sensitive

A limited output function was added. For more flexible output (such as better timezone handling), see local-time - which sadly does not parse RFC-1123, but outputs it.

References: RFC-1123 RFC-822 Section 5


2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 trivial-rfc-1123

minimal parsing of rfc-1123 date-time strings

Author

Stacksmith <fpgasm@apple2.x10.mx>

License

Edi Weitz and BSD 3-clause

Dependency

cl-ppcre (system).

Source

trivial-rfc-1123.asd.

Child Components

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp   [Contents][Index]

3.1.1 trivial-rfc-1123/trivial-rfc-1123.asd

Source

trivial-rfc-1123.asd.

Parent Component

trivial-rfc-1123 (system).

ASDF Systems

trivial-rfc-1123.


3.1.2 trivial-rfc-1123/package.lisp

Source

trivial-rfc-1123.asd.

Parent Component

trivial-rfc-1123 (system).

Packages

trivial-rfc-1123.


3.1.3 trivial-rfc-1123/trivial-rfc-1123.lisp

Dependency

package.lisp (file).

Source

trivial-rfc-1123.asd.

Parent Component

trivial-rfc-1123 (system).

Public Interface
Internals

4 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

4.1 trivial-rfc-1123

Source

package.lisp.

Nickname

t1123

Use List

common-lisp.

Public Interface
Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Public Interface


5.1.1 Ordinary functions

Function: as-rfc-1123 (universal-time &key stream timezone)

format a universal time to string (default) or optional stream, in GMT timezone (unless :timezone option is specified, in Lisp sign-inverted manner. Specifying NIL for timezone will insert machine-local current timezone, which only makes sense for dealing with current time!

Package

trivial-rfc-1123.

Source

trivial-rfc-1123.lisp.

Function: parse-date (string)

Parses a date and returns it as a Lisp universal
time. Currently understands the following formats:

"Wed, 06-Feb-2008 21:01:38 GMT"
"Wed, 06-Feb-08 21:01:38 GMT"
"Tue Feb 13 08:00:00 2007 GMT"
"Wednesday, 07-February-2027 08:55:23 GMT"
"Wed, 07-02-2017 10:34:45 GMT"

Instead of "GMT" time zone abbreviations like "CEST" and UTC offsets like "GMT-01:30" are also allowed.

Package

trivial-rfc-1123.

Source

trivial-rfc-1123.lisp.


5.2 Internals


Next: , Previous: , Up: Internals   [Contents][Index]

5.2.1 Special variables

Special Variable: *time-zone-map*

An alist which maps time zone abbreviations to Common Lisp timezones.

Package

trivial-rfc-1123.

Source

trivial-rfc-1123.lisp.

Special Variable: +day-names+
Package

trivial-rfc-1123.

Source

trivial-rfc-1123.lisp.

Special Variable: +month-names+
Package

trivial-rfc-1123.

Source

trivial-rfc-1123.lisp.


5.2.2 Macros

Macro: when-letx ((var expr) &body body)

Evaluates EXPR, binds it to VAR, and executes BODY if VAR has a true value.

Package

trivial-rfc-1123.

Source

trivial-rfc-1123.lisp.


Next: , Previous: , Up: Internals   [Contents][Index]

5.2.3 Ordinary functions

Function: date-parse-error (format-control &rest format-arguments)

Signals an error of type DATE-PARSE-ERROR with the provided format control and arguments.

Package

trivial-rfc-1123.

Source

trivial-rfc-1123.lisp.

Function: interpret-as-month (string)

Tries to interpret STRING as a string denoting a month and returns the corresponding number of the month. Accepts three-letter abbreviations like "Feb" and full month names likes "February". Finally, the function also accepts strings representing integers from one to twelve.

Package

trivial-rfc-1123.

Source

trivial-rfc-1123.lisp.

Function: interpret-as-time-zone (string)

Tries to interpret STRING as a time zone abbreviation which can either be something like "PST" or "GMT" with an offset like "GMT-02:00".

Package

trivial-rfc-1123.

Source

trivial-rfc-1123.lisp.

Function: safe-parse-integer (string)

Like PARSE-INTEGER, but returns NIL instead of signalling an error.

Package

trivial-rfc-1123.

Source

trivial-rfc-1123.lisp.


5.2.4 Conditions

Condition: date-parse-error

Signaled when the date cannot be parsed.

Package

trivial-rfc-1123.

Source

trivial-rfc-1123.lisp.

Direct superclasses

error.


Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts