Monotone-Parent: 1a5434f30282a4932bf29227da4cf2da44ef5783

Monotone-Revision: ce32e1242b761204db803e0d285c6df7dac31cfb

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2008-07-14T15:12:38
Monotone-Branch: ca.inverse.sogo
maint-2.0.2
Wolfgang Sourdeau 2008-07-14 15:12:38 +00:00
parent 6c5003d7bc
commit 5d0f9faecc
8 changed files with 38 additions and 317 deletions

View File

@ -1,3 +1,20 @@
2008-07-14 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* ICalDateHolder.m: removed class module.
* NSCalendarDate+ICal.m ([NSCalendarDate
+calendarDateWithICalRepresentation:]): removed method.
* iCalRecurrenceCalculator.m: no longer use the
calendarDateWithICalRepresentation: category method (removed), use
NSString's asCalendarDate category method instead.
* iCalRepeatableEntityObject.m ([iCalRepeatableEntityObject
-classForTag:classTag]): instances of EXDATE are of iCalDateTime
class.
([iCalRepeatableEntityObject -exceptionDates]): return the dates
as utc-based date strings.
2008-07-11 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* iCalEntityObject.m ([iCalEntityObject -setRecurrenceId:newRecId])

View File

@ -71,7 +71,6 @@ libNGCards_OBJC_FILES = \
NSDictionary+NGCards.m \
NSString+NGCards.m \
NSCalendarDate+ICal.m \
iCalDateHolder.m \
\
CardElement.m \
CardGroup.m \

View File

@ -28,8 +28,6 @@
@interface NSCalendarDate(iCalRepresentation)
+ (id)calendarDateWithICalRepresentation:(NSString *)_iCalRep;
/* represention */
- (NSString *)icalStringWithTimeZone:(NSTimeZone *)_tz;

View File

@ -25,7 +25,6 @@
#import <NGExtensions/NSCalendarDate+misc.h>
#import "NSCalendarDate+ICal.h"
#import "iCalDateHolder.h"
static NSTimeZone *gmt = nil;
static inline void _setupGMT(void) {
@ -33,27 +32,12 @@ static inline void _setupGMT(void) {
gmt = [[NSTimeZone timeZoneWithAbbreviation:@"GMT"] retain];
}
@interface iCalDateHolder (PrivateAPI)
- (id)awakeAfterUsingSaxDecoder:(id)_decoder;
@end
@implementation NSCalendarDate(iCalRepresentation)
/* represention */
static NSString *gmtcalfmt = @"%Y%m%dT%H%M%SZ";
+ (id)calendarDateWithICalRepresentation:(NSString *)_iCalRep {
iCalDateHolder *dh;
NSCalendarDate *date;
dh = [[iCalDateHolder alloc] init];
[dh setString:_iCalRep];
date = [dh awakeAfterUsingSaxDecoder:nil];
[dh release];
return date;
}
- (NSString *)icalStringInGMT {
NSTimeZone *oldtz;
NSString *s;

View File

@ -1,49 +0,0 @@
/*
Copyright (C) 2000-2005 SKYRIX Software AG
This file is part of SOPE.
SOPE is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public
License along with SOPE; see the file COPYING. If not, write to the
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
#ifndef __NGiCal_iCalDateHolder_H__
#define __NGiCal_iCalDateHolder_H__
#import <Foundation/NSObject.h>
@class NSString, NSTimeZone;
@interface iCalDateHolder : NSObject
{
NSString *tzid;
NSString *string;
NSString *tag;
}
- (void)setString:(NSString *)_value;
- (NSString *)string;
- (void)setTag:(NSString *)_value;
- (NSString *)tag;
- (void)setTzid:(NSString *)_value;
- (NSString *)tzid;
- (NSTimeZone *)timeZone;
@end
#endif /* __NGiCal_iCalDateHolder_H__ */

View File

@ -1,243 +0,0 @@
/*
Copyright (C) 2000-2005 SKYRIX Software AG
This file is part of SOPE.
SOPE is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public
License along with SOPE; see the file COPYING. If not, write to the
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
#import <Foundation/NSDate.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSString.h>
#import <Foundation/NSTimeZone.h>
#import <Foundation/NSUserDefaults.h>
#import <NGExtensions/NSCalendarDate+misc.h>
#import <NGExtensions/NSObject+Logs.h>
#import "iCalDateHolder.h"
#import "iCalObject.h"
@interface NSTimeZone(iCalTimeZone)
+ (NSTimeZone *)timeZoneWithICalId:(NSString *)_tz;
@end
@implementation iCalDateHolder
static NSTimeZone *gmt = nil;
+ (void)initialize {
if (gmt == nil)
gmt = [[NSTimeZone timeZoneWithName:@"GMT"] retain];
}
- (void)dealloc {
[self->tzid release];
[self->string release];
[self->tag release];
[super dealloc];
}
/* accessors */
- (void)setString:(NSString *)_value {
ASSIGNCOPY(self->string, _value);
}
- (NSString *)string {
return self->string;
}
- (void)setTag:(NSString *)_value {
ASSIGNCOPY(self->tag, _value);
}
- (NSString *)tag {
return self->tag;
}
- (void)setTzid:(NSString *)_value {
ASSIGNCOPY(self->tzid, _value);
}
- (NSString *)tzid {
return self->tzid;
}
/* mapping to Foundation */
- (NSTimeZone *)timeZone {
// TODO: lookup tzid in iCalCalendar !
NSString *s;
s = [self tzid];
/* a hack */
if ([s hasPrefix:@"/softwarestudio.org"]) {
NSRange r;
r = [s rangeOfString:@"Europe/"];
if (r.length > 0)
s = [s substringFromIndex:r.location];
}
return [NSTimeZone timeZoneWithICalId:s];
}
/* decoding */
- (id)awakeAfterUsingSaxDecoder:(id)_decoder {
NSCalendarDate *date = nil;
NSString *s;
NSTimeZone *tz;
s = self->string;
if ([s length] < 5) {
[self logWithFormat:@"tag %@: got an weird date string '%@' ?!",
self->tag, s];
return s;
}
/* calculate timezone */
if ([self->string hasSuffix:@"Z"]) {
/* zulu time, eg 20021009T094500Z */
tz = gmt;
s = [s substringToIndex:([s length] - 1)];
}
else
tz = [self timeZone];
/*
012345678901234
20021009T094500 - 15 chars
20021009T0945 - 13 chars
991009T0945 - 11 chars
20031111 - 8 chars
*/
if ([s rangeOfString:@"T"].length == 0 && [s length] == 8) {
/* hm, maybe a date without a time? like an allday event! */
int year, month, day;
char *buf;
buf = strdup([s cStringUsingEncoding: NSASCIIStringEncoding]);
day = atoi(buf + 6);
buf[6] = '\0';
month = atoi(buf + 4);
buf[4] = '\0';
year = atoi(buf);
free (buf);
date = [NSCalendarDate dateWithYear:year month:month day:day
hour:0 minute:0 second:0
timeZone:tz];
}
else if ([s length] == 15) {
int year, month, day, hour, minute, second;
char buf[24];
[s getCString:&(buf[0])];
second = atoi(&(buf[13])); buf[13] = '\0';
minute = atoi(&(buf[11])); buf[11] = '\0';
hour = atoi(&(buf[9])); buf[9] = '\0';
day = atoi(&(buf[6])); buf[6] = '\0';
month = atoi(&(buf[4])); buf[4] = '\0';
year = atoi(&(buf[0]));
date = [NSCalendarDate dateWithYear:year month:month day:day
hour:hour minute:minute second:second
timeZone:tz];
}
else
NSLog(@"%s: unknown date format (%@) ???", __PRETTY_FUNCTION__, s);
if (date == nil)
NSLog(@"couldn't convert string '%@' to date (format '%@') ..", s);
return date;
}
/* description */
- (void)appendAttributesToDescription:(NSMutableString *)ms {
if (self->tag) [ms appendFormat:@" %@", self->tag];
if (self->string) [ms appendFormat:@" '%@'", self->string];
if (self->tzid) [ms appendFormat:@" tz=%@", self->tzid];
}
- (NSString *)description {
NSMutableString *ms;
ms = [NSMutableString stringWithCapacity:128];
[ms appendFormat:@"<0x%p[%@]:", self, NSStringFromClass([self class])];
[self appendAttributesToDescription:ms];
[ms appendString:@">"];
return ms;
}
@end /* iCalDateHolder */
@implementation NSTimeZone(iCalTimeZone)
static NSMutableDictionary *idToTz = nil; // THREAD
+ (NSTimeZone *)timeZoneWithICalId:(NSString *)_tzid {
static NSString *iCalDefaultTZ = nil;
NSTimeZone *tz;
if (idToTz == nil)
idToTz = [[NSMutableDictionary alloc] initWithCapacity:16];
if ([_tzid length] == 0) {
tz = [iCalObject iCalDefaultTimeZone];
if (tz != nil) return tz;
if (iCalDefaultTZ == nil) {
NSString *defTz;
NSUserDefaults *ud;
// TODO: take a default timeZone
ud = [NSUserDefaults standardUserDefaults];
defTz = [ud stringForKey:@"iCalTimeZoneName"];
if ([defTz length] == 0)
defTz = [ud stringForKey:@"TimeZoneName"];
if ([defTz length] == 0)
defTz = [ud stringForKey:@"TimeZone"];
if ([defTz length] == 0)
defTz = @"GMT";
iCalDefaultTZ = [defTz retain];
}
_tzid = iCalDefaultTZ;
}
if ([_tzid length] == 0)
_tzid = @"GMT";
tz = [idToTz objectForKey:_tzid];
if (tz == nil) tz = [NSTimeZone timeZoneWithName:_tzid];
if (tz == nil) tz = [NSTimeZone timeZoneWithAbbreviation:_tzid];
if (tz == nil) {
NSLog(@"couldn't map timezone id %@", _tzid);
}
if (tz) [idToTz setObject:tz forKey:_tzid];
return tz;
}
@end /* NSTimeZone(iCalTimeZone) */

View File

@ -27,8 +27,7 @@
#import <NGExtensions/NSObject+Logs.h>
#import "iCalRecurrenceRule.h"
#import "NSCalendarDate+ICal.h"
#import "NSString+NGCards.h"
#import "iCalRecurrenceCalculator.h"
@ -173,9 +172,7 @@ static Class yearlyCalcClass = Nil;
while ((currentDate = [dates nextObject]))
{
if ([currentDate isKindOfClass: NSStringClass])
currentDate
= [NSCalendarDate
calendarDateWithICalRepresentation: (NSString *) currentDate];
currentDate = [(NSString *) currentDate asCalendarDate];
if ([limits containsDate: currentDate])
[newDates addObject: currentDate];
}

View File

@ -26,6 +26,8 @@
#import <NGExtensions/NGCalendarDateRange.h>
#import "NSCalendarDate+NGCards.h"
#import "iCalDateTime.h"
#import "iCalRecurrenceRule.h"
#import "iCalRecurrenceCalculator.h"
#import "iCalRepeatableEntityObject.h"
@ -38,6 +40,8 @@
if ([classTag isEqualToString: @"RRULE"])
tagClass = [iCalRecurrenceRule class];
else if ([classTag isEqualToString: @"EXDATE"])
tagClass = [iCalDateTime class];
else
tagClass = [super classForTag: classTag];
@ -121,7 +125,21 @@
- (NSArray *) exceptionDates
{
return [self childrenWithTag: @"exdate"];
NSMutableArray *dates;
NSEnumerator *dateList;
NSCalendarDate *exDate;
NSString *dateString;
dates = [NSMutableArray array];
dateList = [[self childrenWithTag: @"exdate"] objectEnumerator];
while ((exDate = [[dateList nextObject] dateTime]))
{
dateString = [NSString stringWithFormat: @"%@Z",
[exDate iCalFormattedDateTimeString]];
[dates addObject: dateString];
}
return dates;
}
/* Convenience */