From 198ca8e76ed5db4bb3778e21205f4d3d7ac5b2bb Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 4 Oct 2006 23:12:08 +0000 Subject: [PATCH] Monotone-Parent: 9ae32cf8559ea63dc0055f1841da04821ed5e5ee Monotone-Revision: dd288587ff94f2fc40c82dd8e32cf52f45b50841 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2006-10-04T23:12:08 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 12 ++++ SoObjects/SOGo/GNUmakefile | 3 +- .../SOGo/NSCalendarDate+SOGo.h | 15 +++- .../SOGo/NSCalendarDate+SOGo.m | 70 ++++++++++++++++++- UI/Scheduler/GNUmakefile | 1 - 5 files changed, 94 insertions(+), 7 deletions(-) rename UI/Scheduler/NSCalendarDate+Scheduler.h => SoObjects/SOGo/NSCalendarDate+SOGo.h (72%) rename UI/Scheduler/NSCalendarDate+Scheduler.m => SoObjects/SOGo/NSCalendarDate+SOGo.m (51%) diff --git a/ChangeLog b/ChangeLog index 1df164867..e77d6da1b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,17 @@ 2006-10-04 Wolfgang Sourdeau + * SoObjects/SOGo/NSCalendarDate+SOGo.m: module replacing and + extending UI/Scheduler/NSCalendarDate+Scheduler.m. + ([NSCalendarDate + +dateFromShortDateString:dateStringandShortTimeString:timeStringinTimeZone:timeZone]): new method that generates a date from two short string formatted as follow: "yyyymmdd" and "hhmm". Thismethod replaces a similar method from UIxComponent (noted below). + ([NSCalendarDate -adjustedDate]): this method returns another + instance set to the correct hour after the original date was set + from a non-GMT timezone. This date can be used for storage. + ([NSCalendarDate -driftedDate]): this method does exactly the + opposite of -adjutedDate, that is, it enables the method + hourOfDay, minuteOfHour etc... to return the values according to + the original date's timezone. This date CANNOT be used for storage. + * UI/Scheduler/NSCalendarDate+Scheduler.m ([NSCalendarDate -shortDateString]): new method that will return a "short date string" (yyyymmdd) from a calendar date object. diff --git a/SoObjects/SOGo/GNUmakefile b/SoObjects/SOGo/GNUmakefile index 60dc38768..a66052ce1 100644 --- a/SoObjects/SOGo/GNUmakefile +++ b/SoObjects/SOGo/GNUmakefile @@ -34,6 +34,7 @@ libSOGo_HEADER_FILES = \ WOContext+Agenor.h \ NSString+URL.h \ NSDictionary+URL.h \ + NSCalendarDate+SOGo.h \ \ SOGoAuthenticator.h \ SOGoUser.h \ @@ -54,7 +55,7 @@ libSOGo_OBJC_FILES = \ AgenorUserDefaults.m \ NSDictionary+URL.m \ NSString+URL.m \ - \ + NSCalendarDate+SOGo.m \ \ SOGoAuthenticator.m \ SOGoUser.m \ diff --git a/UI/Scheduler/NSCalendarDate+Scheduler.h b/SoObjects/SOGo/NSCalendarDate+SOGo.h similarity index 72% rename from UI/Scheduler/NSCalendarDate+Scheduler.h rename to SoObjects/SOGo/NSCalendarDate+SOGo.h index 18bcd310c..ec4c8f85f 100644 --- a/UI/Scheduler/NSCalendarDate+Scheduler.h +++ b/SoObjects/SOGo/NSCalendarDate+SOGo.h @@ -1,4 +1,4 @@ -/* NSCalendarDate+Scheduler.h - this file is part of SOGo +/* NSCalendarDate+SOGo.h - this file is part of SOGo Copyright (C) 2000-2004 SKYRIX Software AG This file is part of OGo @@ -24,7 +24,18 @@ #import -@interface NSCalendarDate (SchedulerExtensions) +@class NSString; +@class NSTimeZone; + +@interface NSCalendarDate (SOGoExtensions) + ++ (id) dateFromShortDateString: (NSString *) dateString + andShortTimeString: (NSString *) timeString + inTimeZone: (NSTimeZone *) timeZone; + +/* a date tuned to its timezone when initialized with local values */ +- (NSCalendarDate *) adjustedDate; +- (NSCalendarDate *) driftedDate; - (BOOL) isDateInSameMonth: (NSCalendarDate *) _other; - (NSCalendarDate *) dayOfWeeK: (unsigned) _day diff --git a/UI/Scheduler/NSCalendarDate+Scheduler.m b/SoObjects/SOGo/NSCalendarDate+SOGo.m similarity index 51% rename from UI/Scheduler/NSCalendarDate+Scheduler.m rename to SoObjects/SOGo/NSCalendarDate+SOGo.m index e736217da..67fd8902c 100644 --- a/UI/Scheduler/NSCalendarDate+Scheduler.m +++ b/SoObjects/SOGo/NSCalendarDate+SOGo.m @@ -1,4 +1,4 @@ -/* NSCalendarDate+Scheduler.m - this file is part of SOGo +/* NSCalendarDate+SOGo.m - this file is part of SOGo Copyright (C) 2000-2004 SKYRIX Software AG This file is part of OGo @@ -21,9 +21,73 @@ #import -#import "NSCalendarDate+Scheduler.h" +#import "NSCalendarDate+SOGo.h" -@implementation NSCalendarDate (SchedulerExtensions) +@implementation NSCalendarDate (SOGoExtensions) + ++ (id) dateFromShortDateString: (NSString *) dateString + andShortTimeString: (NSString *) timeString + inTimeZone: (NSTimeZone *) timeZone +{ + unsigned int year, month, day, hour, minute, total; + NSCalendarDate *cDate, *tmpDate; + + if (dateString && [dateString length] == 8) + { + total = [dateString intValue]; + year = total / 10000; + total -= year * 10000; + month = total / 100; + day = total - (month * 100); + } + else + { + tmpDate = [NSCalendarDate calendarDate]; + tmpDate = [tmpDate addYear: 0 month: 0 day: 0 hour: 0 minute: 0 + second: [timeZone secondsFromGMT]]; + year = [tmpDate yearOfCommonEra]; + month = [tmpDate monthOfYear]; + day = [tmpDate dayOfMonth]; + } + + if (timeString && [timeString length] == 4) + { + total = [timeString intValue]; + hour = total / 100; + minute = total - (hour * 100); + } + else + { + hour = 12; + minute = 0; + } + + cDate = [self dateWithYear: year month: month day: day + hour: hour minute: minute second: 0 + timeZone: timeZone]; + + return [cDate adjustedDate]; +} + +- (NSCalendarDate *) adjustedDate +{ + NSTimeZone *dTZ; + + dTZ = [self timeZone]; + + return [self addYear: 0 month: 0 day: 0 hour: 0 minute: 0 + second: -[dTZ secondsFromGMT]]; +} + +- (NSCalendarDate *) driftedDate +{ + NSTimeZone *dTZ; + + dTZ = [self timeZone]; + + return [self addYear: 0 month: 0 day: 0 hour: 0 minute: 0 + second: [dTZ secondsFromGMT]]; +} - (BOOL) isDateInSameMonth: (NSCalendarDate *) _other { diff --git a/UI/Scheduler/GNUmakefile b/UI/Scheduler/GNUmakefile index 0ed5913ad..52b751cc1 100644 --- a/UI/Scheduler/GNUmakefile +++ b/UI/Scheduler/GNUmakefile @@ -10,7 +10,6 @@ SchedulerUI_LANGUAGES = English French German SchedulerUI_OBJC_FILES = \ SchedulerUIProduct.m \ - NSCalendarDate+Scheduler.m \ \ UIxCalMainView.m \ \