package http-date
Module Http_dateSource
HTTP timestamp decoders and encoders complaint to RFC 9110 (HTTP Semantics).
The current supported formats for decoding/encoding are as follows:
- IMF(Internet Message Format) date, eg
"Sun, 06 Nov 1994 08:49:37 GMT" - RFC 850 date, eg
"Sunday, 06-Nov-94 08:49:37 GMT"Obsolete - asctime date, eg
"Sun Nov 6 08:49:37 1994"Obsolete
HTTP timestamps are always in GMT/UTC
References
- RFC 9110. Date/Time Formats
decode s is ptime if s contains a valid textual representation of formats defined in encoding.
century An integer value representing century component of a year. This is used to decode the correct year component of ptime, if s contains RFC 850 encoded date value, e.g. year 96 is decoded as 1996 if century = 19. If century is not given, then the decoded year component is used as is, i.e. 96.
decoding string in IMF fix date format:
Http_date.decode "Sun, 06 Nov 1994 08:49:37 GMT"Encode HTTP timestamps
encode ?encoding ptime encodes ptime into a given encoding textual representation. The default value of encoding is IMF.
Pretty Printing timestamps
pp ?encoding fmt ptime is like encode ?encoding ptime except it prints out to fmt instead of a string.