2 Copyright (C) 2000-2004 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
24 #import "SOGoDateFormatter.h"
25 #import <NGExtensions/NGExtensions.h>
28 @interface SOGoDateFormatter (PrivateAPI)
29 - (NSString *)shortDayOfWeek:(int)_day;
30 - (NSString *)fullDayOfWeek:(int)_day;
31 - (NSString *)shortMonthOfYear:(int)_month;
32 - (NSString *)fullMonthOfYear:(int)_month;
34 - (NSString *)isoDateFormatForDate:(NSCalendarDate *)_date;
35 - (NSString *)fullWeekdayNameAndDetailsForDate:(NSCalendarDate *)_date;
39 @implementation SOGoDateFormatter
41 - (id)initWithLocale:(NSDictionary *)_locale {
44 ASSIGN(self->locale, _locale);
45 [self setISODateFormat];
51 [self->locale release];
55 - (void)setISODateFormat {
56 self->formatAction = @selector(isoDateFormatForDate:);
59 - (void)setFullWeekdayNameAndDetails {
60 self->formatAction = @selector(fullWeekdayNameAndDetailsForDate:);
63 - (NSString *)stringForObjectValue:(id)_obj {
64 return [self performSelector:self->formatAction
71 - (NSString *)shortDayOfWeek:(int)_day {
72 return [[self->locale objectForKey:@"NSShortWeekDayNameArray"]
76 - (NSString *)fullDayOfWeek:(int)_day {
77 return [[self->locale objectForKey:@"NSWeekDayNameArray"]
81 - (NSString *)shortMonthOfYear:(int)_month {
82 return [[self->locale objectForKey:@"NSShortMonthNameArray"]
83 objectAtIndex:_month - 1];
86 - (NSString *)fullMonthOfYear:(int)_month {
87 return [[self->locale objectForKey:@"NSMonthNameArray"]
88 objectAtIndex:_month - 1];
94 - (NSString *)isoDateFormatForDate:(NSCalendarDate *)_date {
95 return [NSString stringWithFormat:@"%d-%02d-%02d",
96 [_date yearOfCommonEra],
101 - (NSString *)fullWeekdayNameAndDetailsForDate:(NSCalendarDate *)_date {
102 NSMutableString *desc;
104 desc = [[NSMutableString alloc] init];
105 [desc appendString:[self fullDayOfWeek:[_date dayOfWeek]]];
106 [desc appendString:@", "];
107 [desc appendString:[self isoDateFormatForDate:_date]];
108 [desc appendString:@" "];
109 [desc appendFormat:@"%02d:%02d ",
111 [_date minuteOfHour]];
112 [desc appendString:[[_date timeZone] name]];
113 return [desc autorelease];