[Pharo-project] Parsing HTTP dates
Excerpt from http://forum.world.st/Parsing-HTTP-dates-td4623583.html : In HTTP/1.1, valid dates come in 3 forms (per http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1) : Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123 Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036 Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format All 3 fail in Pharo 1.4 with #asDateAndTime. I posted this to the Seaside list because it seems like there *must* be some code out there... This would be a nice utility for Zinc... -- View this message in context: http://forum.world.st/Parsing-HTTP-dates-tp4623688.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
Sean, On 10 May 2012, at 16:39, Sean P. DeNigris wrote:
Excerpt from http://forum.world.st/Parsing-HTTP-dates-td4623583.html :
In HTTP/1.1, valid dates come in 3 forms (per http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1) : Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123 Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036 Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format
All 3 fail in Pharo 1.4 with #asDateAndTime.
I posted this to the Seaside list because it seems like there *must* be some code out there... This would be a nice utility for Zincâ¦
You are underestimating me again ;-) This has been in Zn since a very long time: ZnUtils>>parseHttpDate: string "self parseHttpDate: 'Tue, 13 Sep 2011 08:04:49 GMT'." "self parseHttpDate: 'Tue, 13-Sep-2011 08:04:51 GMT'." "self parseHttpDate: 'Tue Jan 01 00:00:01 2036 GMT'." That should cover the spec, no ? Regards, Sven -- Sven Van Caekenberghe http://stfx.eu Smalltalk is the Red Pill
Sven Van Caekenberghe wrote
You are underestimating me again ;-)
Ha ha. You're too good. I'm not used to this level of service ;-) Sven Van Caekenberghe wrote
ZnUtils>>parseHttpDate: string
Damn, I was looking for a ZnDate* Sven Van Caekenberghe wrote
That should cover the spec, no ?
For the 3 examples I pasted from the standard: - 'Sun, 06 Nov 1994 08:49:37 GMT' -> works fine - 'Sunday, 06-Nov-94 08:49:37 GMT' -> parses, but doesn't convert the year to 4 digit (thinks it's 0094) - 'Sun Nov 6 08:49:37 1994' -> fails to parse. it seems GMT is optional, but should be assumed if not present -- View this message in context: http://forum.world.st/Parsing-HTTP-dates-tp4623688p4623838.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
I patched the parser to succeed for all 3 examples and updated the tests, which all pass. I uploaded the packages to the SqS repository. The parsing method is now ugly. I would break it out into a separate class (or at least some private methods), but I just made it work and left it to you to decide... Sean -- View this message in context: http://forum.world.st/Parsing-HTTP-dates-tp4623688p4623932.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
On 10 May 2012, at 18:28, Sean P. DeNigris wrote:
I patched the parser to succeed for all 3 examples and updated the tests, which all pass. I uploaded the packages to the SqS repository.
The parsing method is now ugly. I would break it out into a separate class (or at least some private methods), but I just made it work and left it to you to decide...
Sean
Patches merged and accepted. Thanks a lot, Sean, I was about to suggest you fixed the problem yourself but you read my mind ;-) It is like one of Marcus' quotes that I lilke so much: 'It is you Pharo'. We have to make things better, one little step at a time, for all of us together. Sven
participants (3)
-
Sean P. DeNigris -
Stéphane Ducasse -
Sven Van Caekenberghe