2 Copyright (C) 2000-2005 SKYRIX Software AG
4 This file is part of SOPE.
6 SOPE is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with SOPE; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
24 @implementation NSCalendarDate(RFC822Dates)
26 static NSString *dateFormats[] = {
28 short-weekday, day short-month year hour:minute:second timezoneoffset
29 eg: Mon, 01 Mar 1999 13:13:13 +0000
31 @"%a, %d %b %Y %H:%M:%S %z",
34 short-weekday, day short-month year hour:minute:second timezonename
35 eg: Mon, 01 Mar 1999 13:13:13 GMT
37 @"%a, %d %b %Y %H:%M:%S %Z",
40 short-weekday, day short-month year hour:minute:second timezonename
41 eg: Mon, 01 Mar 1999 13:13 +0000
43 @"%a, %d %b %Y %H:%M %z",
46 short-weekday, day short-month year hour:minute:second timezonename
47 eg: Mon, 01 Mar 1999 13:13 (+0000)
49 @"%a, %d %b %Y %H:%M (%z)",
52 short-weekday, day short-month year hour:minute:second timezonename
53 eg: Mon, 01 Mar 1999 13:13 (GMT)
55 @"%a, %d %b %Y %H:%M (%Z)",
58 short-weekday, day short-month year hour:minute:second
59 eg: Mon, 01 Mar 1999 13:13:13
61 @"%a, %d %b %Y %H:%M:%S",
64 day short-month year hour:minute:second timezoneoffset
65 eg: 01 Oct 1999 18:20:12 +0200
67 @"%d %b %Y %H:%M:%S %z",
70 day short-month year hour:minute:second timezonename
71 eg: 01 Oct 1999 18:20:12 EST
73 @"%d %b %Y %H:%M:%S %Z",
76 day short-month year hour:minute:second (timezoneoffset)
77 eg: 30 Sep 1999 21:00:05 (+0200)
79 @"%d %b %Y %H:%M:%S (%z)",
82 day short-month year hour:minute:second (timezonename)
83 eg: 30 Sep 1999 21:00:05 (MEST)
85 @"%d %b %Y %H:%M:%S (%Z)",
87 day short-month year hour:minute:second (timezonename)
88 eg: 30 Sep 1999 21:00:05 (MEST)
90 @"%d %b %Y %H:%M:%S (%Z)",
93 short-weekday, day short-month year hour:minute:second timezoneoffset
94 eg: Mon, 01 Mar 1999 13:13:13 +0000
96 @"%a %b %d %H:%M:%S %Y (%Z)",
99 eg: '16 Jun 2002 10:28 GMT'
101 @"%d %b %Y %H:%M %Z",
104 eg: '16 Jun 2002 10:28 +0000'
106 @"%d %b %Y %H:%M %z",
112 + (NSCalendarDate *)calendarDateWithRfc822DateString:(NSString *)_str {
113 // TODO: optimize MUCH more - calformat parsing is *slow*
114 NSCalendarDate *date = nil;
115 NSString *dateString = nil;
118 dateString = [_str stringByTrimmingSpaces];
119 if ([dateString length] == 0)
122 /* check various date formats */
124 for (i = 0, date = nil; (date == nil) && (dateFormats[i] != nil); i++) {
125 date = [NSCalendarDate dateWithString:dateString
126 calendarFormat:dateFormats[i]];
128 return [date y2kDate];
131 @end /* NSCalendarDate(RFC822Dates) */