I'd like to know if Flash/AS3 has any nice way to convert an AS3 'Date' object to/from rfc-850 timestamp format (as used by HTTP date and last-modified).
This question is very similar to this question about rfc 3339, except it's specific to AS3 and rfc-850.
RFC-850 is like: Thu, 09 Oct 2008 01:09:43 GMT
Best Solution
Alright, so here's a couple of functions to do RFC-802/
Date
conversion in Flash.I learned that the
Date
object doesn't really have any notion of a timezone, and assumes that it is in the local timezone. If you pass an RFC-802 date to theDate()
constructor, it parses it everything except the "GMT" timezone token at the end, resulting in the correct time but possibly in the wrong timezone.Subtracting the current timezone from the parsed Date compensates for this, so a timestamp can do a round-trip with these functions without becoming completely wrong.
(Wouldn't it have been great if somebody had included a
timezone
property when they were designing theDate
class?)