2 Copyright (C) 2000-2003 SKYRIX Software AG
4 This file is part of OGo
6 OGo 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 OGo 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 OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
25 @implementation NSCalendarDate(RFC822Dates)
27 static NSString *dateFormats[] = {
29 short-weekday, day short-month year hour:minute:second timezoneoffset
30 eg: Mon, 01 Mar 1999 13:13:13 +0000
32 @"%a, %d %b %Y %H:%M:%S %z",
35 short-weekday, day short-month year hour:minute:second timezonename
36 eg: Mon, 01 Mar 1999 13:13:13 GMT
38 @"%a, %d %b %Y %H:%M:%S %Z",
41 short-weekday, day short-month year hour:minute:second timezonename
42 eg: Mon, 01 Mar 1999 13:13 +0000
44 @"%a, %d %b %Y %H:%M %z",
47 short-weekday, day short-month year hour:minute:second timezonename
48 eg: Mon, 01 Mar 1999 13:13 (+0000)
50 @"%a, %d %b %Y %H:%M (%z)",
53 short-weekday, day short-month year hour:minute:second timezonename
54 eg: Mon, 01 Mar 1999 13:13 (GMT)
56 @"%a, %d %b %Y %H:%M (%Z)",
59 short-weekday, day short-month year hour:minute:second
60 eg: Mon, 01 Mar 1999 13:13:13
62 @"%a, %d %b %Y %H:%M:%S",
65 day short-month year hour:minute:second timezoneoffset
66 eg: 01 Oct 1999 18:20:12 +0200
68 @"%d %b %Y %H:%M:%S %z",
71 day short-month year hour:minute:second timezonename
72 eg: 01 Oct 1999 18:20:12 EST
74 @"%d %b %Y %H:%M:%S %Z",
77 day short-month year hour:minute:second (timezoneoffset)
78 eg: 30 Sep 1999 21:00:05 (+0200)
80 @"%d %b %Y %H:%M:%S (%z)",
83 day short-month year hour:minute:second (timezonename)
84 eg: 30 Sep 1999 21:00:05 (MEST)
86 @"%d %b %Y %H:%M:%S (%Z)",
88 day short-month year hour:minute:second (timezonename)
89 eg: 30 Sep 1999 21:00:05 (MEST)
91 @"%d %b %Y %H:%M:%S (%Z)",
94 short-weekday, day short-month year hour:minute:second timezoneoffset
95 eg: Mon, 01 Mar 1999 13:13:13 +0000
97 @"%a %b %d %H:%M:%S %Y (%Z)",
100 eg: '16 Jun 2002 10:28 GMT'
102 @"%d %b %Y %H:%M %Z",
105 eg: '16 Jun 2002 10:28 +0000'
107 @"%d %b %Y %H:%M %z",
113 + (NSCalendarDate *)calendarDateWithRfc822DateString:(NSString *)_str {
114 // TODO: optimize MUCH more - calformat parsing is *slow*
115 NSCalendarDate *date = nil;
116 NSString *dateString = nil;
119 dateString = [_str stringByTrimmingSpaces];
120 if ([dateString length] == 0)
123 /* check various date formats */
125 for (i = 0, date = nil; (date == nil) && (dateFormats[i] != nil); i++) {
126 date = [NSCalendarDate dateWithString:dateString
127 calendarFormat:dateFormats[i]];
129 return [date y2kDate];
132 @end /* NSCalendarDate(RFC822Dates) */