/*
- Copyright (C) 2000-2004 SKYRIX Software AG
+ Copyright (C) 2004 SKYRIX Software AG
- This file is part of OGo
+ This file is part of OpenGroupware.org.
OGo 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, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
-
-
-#import "SOGoDateFormatter.h"
-#import <NGExtensions/NGExtensions.h>
+#include "SOGoDateFormatter.h"
+#include "common.h"
@interface SOGoDateFormatter (PrivateAPI)
- (NSString *)shortDayOfWeek:(int)_day;
- (NSString *)fullWeekdayNameAndDetailsForDate:(NSCalendarDate *)_date;
@end
-
@implementation SOGoDateFormatter
- (id)initWithLocale:(NSDictionary *)_locale {
- self = [super init];
- if(self) {
- ASSIGN(self->locale, _locale);
- [self setISODateFormat];
- }
- return self;
+ if ((self = [super init])) {
+ self->locale = [_locale retain];
+ [self setISODateFormat];
+ }
+ return self;
}
- (void)dealloc {
- [self->locale release];
- [super dealloc];
+ [self->locale release];
+ [super dealloc];
}
+/* accessors */
+
- (void)setISODateFormat {
- self->formatAction = @selector(isoDateFormatForDate:);
+ self->formatAction = @selector(isoDateFormatForDate:);
}
- (void)setFullWeekdayNameAndDetails {
- self->formatAction = @selector(fullWeekdayNameAndDetailsForDate:);
+ self->formatAction = @selector(fullWeekdayNameAndDetailsForDate:);
}
+/* operation */
+
- (NSString *)stringForObjectValue:(id)_obj {
- return [self performSelector:self->formatAction
- withObject:_obj];
+ return [self performSelector:self->formatAction
+ withObject:_obj];
}
-
/* Helpers */
- (NSString *)shortDayOfWeek:(int)_day {
- return [[self->locale objectForKey:@"NSShortWeekDayNameArray"]
- objectAtIndex:_day];
+ return [[self->locale objectForKey:@"NSShortWeekDayNameArray"]
+ objectAtIndex:_day];
}
- (NSString *)fullDayOfWeek:(int)_day {
- return [[self->locale objectForKey:@"NSWeekDayNameArray"]
- objectAtIndex:_day];
+ return [[self->locale objectForKey:@"NSWeekDayNameArray"]
+ objectAtIndex:_day];
}
- (NSString *)shortMonthOfYear:(int)_month {
- return [[self->locale objectForKey:@"NSShortMonthNameArray"]
- objectAtIndex:_month - 1];
+ return [[self->locale objectForKey:@"NSShortMonthNameArray"]
+ objectAtIndex:_month - 1];
}
- (NSString *)fullMonthOfYear:(int)_month {
- return [[self->locale objectForKey:@"NSMonthNameArray"]
- objectAtIndex:_month - 1];
+ return [[self->locale objectForKey:@"NSMonthNameArray"]
+ objectAtIndex:_month - 1];
}
/* Private API */
- (NSString *)isoDateFormatForDate:(NSCalendarDate *)_date {
- return [NSString stringWithFormat:@"%d-%02d-%02d",
- [_date yearOfCommonEra],
- [_date monthOfYear],
- [_date dayOfMonth]];
+ return [NSString stringWithFormat:@"%04d-%02d-%02d",
+ [_date yearOfCommonEra],
+ [_date monthOfYear],
+ [_date dayOfMonth]];
}
- (NSString *)fullWeekdayNameAndDetailsForDate:(NSCalendarDate *)_date {
- NSMutableString *desc;
-
- desc = [[NSMutableString alloc] init];
- [desc appendString:[self fullDayOfWeek:[_date dayOfWeek]]];
- [desc appendString:@", "];
- [desc appendString:[self isoDateFormatForDate:_date]];
- [desc appendString:@" "];
- [desc appendFormat:@"%02d:%02d ",
- [_date hourOfDay],
- [_date minuteOfHour]];
- [desc appendString:[[_date timeZone] name]];
- return [desc autorelease];
+ NSMutableString *desc;
+
+ desc = [NSMutableString stringWithCapacity:24];
+ [desc appendString:[self fullDayOfWeek:[_date dayOfWeek]]];
+ [desc appendString:@", "];
+ [desc appendString:[self isoDateFormatForDate:_date]];
+ [desc appendString:@" "];
+ [desc appendFormat:@"%02d:%02d ", [_date hourOfDay], [_date minuteOfHour]];
+ [desc appendString:[[_date timeZone] abbreviation]];
+ return desc;
}
-@end
+@end /* SOGoDateFormatter */
--- /dev/null
+/*
+ Copyright (C) 2004 SKYRIX Software AG
+
+ This file is part of OpenGroupware.org.
+
+ OGo 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.
+
+ OGo 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 OGo; see the file COPYING. If not, write to the
+ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+*/
+
+#import <Foundation/Foundation.h>
+#include <NGExtensions/NGExtensions.h>
+
+#include <NGObjWeb/NGObjWeb.h>
+#include <NGObjWeb/SoObjects.h>