nmdias / FeedKit

An RSS, Atom and JSON Feed parser written in Swift
MIT License
1.19k stars 174 forks source link

Add another date format #123

Closed lironxyz closed 1 year ago

lironxyz commented 4 years ago

Hi there!

Thank you for this awesome repository!

Could you please add the following format? : "Sat, 30 May 2020 21:38:40" (RFC2822, https://tools.ietf.org/html/rfc2822)

If you guys could just point me to the correct DateFormatter, I'll add the format myself and open a PR for this.

Thank you very much!

GarthSnyder commented 4 years ago

I don't think this format is actually compliant with RFC2822 (well, RFC5322 now) since it doesn't include a time zone. Take a look at section 3.3 here and see what you think.

You can add this to the backupFormats list in RFC822DateFormatter.swift. That's the right place for formats that purport to be RFC822-class dates but aren't actually compliant (but that are nevertheless found in real-world feeds). It looks like the time zone will default to GMT, which seems reasonable. But it's probably worth verifying on some test feeds.

If you would, please add a version of the format that drops the day-of-week prefix (and comma) as well, since that seems to be a common mutation of RFC822 dates.

nmdias commented 1 year ago

Thank you for the issue @lironxyz and @GarthSnyder for helping out. If you feel you still need this, kindly open again.

Cheers