diff --git a/SoObjects/Appointments/iCalEntityObject+SOGo.h b/SoObjects/Appointments/iCalEntityObject+SOGo.h index e46da0b69..32b3a50dc 100644 --- a/SoObjects/Appointments/iCalEntityObject+SOGo.h +++ b/SoObjects/Appointments/iCalEntityObject+SOGo.h @@ -56,8 +56,6 @@ extern NSNumber *iCalDistantFutureNumber; - (int) priorityNumber; - (NSDictionary *) createdBy; -- (NSCalendarDate *) dateFromString: (NSString *) dateString - inContext: (WOContext *) context; - (void) adjustDate: (NSCalendarDate **) date withTimeString: (NSString *) timeString inContext: (WOContext *) context; diff --git a/SoObjects/Appointments/iCalEntityObject+SOGo.m b/SoObjects/Appointments/iCalEntityObject+SOGo.m index fe9ad4c93..28ee1d44c 100644 --- a/SoObjects/Appointments/iCalEntityObject+SOGo.m +++ b/SoObjects/Appointments/iCalEntityObject+SOGo.m @@ -173,36 +173,6 @@ NSNumber *iCalDistantFutureNumber = nil; return data; } -// From [UIxDatePicker takeValuesFromRequest:inContext:] -- (NSCalendarDate *) dateFromString: (NSString *) dateString - inContext: (WOContext *) context -{ - NSInteger dateTZOffset, userTZOffset; - NSTimeZone *systemTZ, *userTZ; - SOGoUserDefaults *ud; - NSCalendarDate *date; - - date = [NSCalendarDate dateWithString: dateString - calendarFormat: @"%Y-%m-%d"]; - if (!date) - [self warnWithFormat: @"Could not parse dateString: '%@'", dateString]; - - // We must adjust the date timezone because "dateWithString:..." uses the - // system timezone, which can be different from the user's. */ - ud = [[context activeUser] userDefaults]; - systemTZ = [date timeZone]; - dateTZOffset = [systemTZ secondsFromGMTForDate: date]; - userTZ = [ud timeZone]; - userTZOffset = [userTZ secondsFromGMTForDate: date]; - if (dateTZOffset != userTZOffset) - date = [date dateByAddingYears: 0 months: 0 days: 0 - hours: 0 minutes: 0 - seconds: (dateTZOffset - userTZOffset)]; - [date setTimeZone: userTZ]; - - return date; -} - // From [UIxTimeDatePicker takeValuesFromRequest:inContext:] - (void) adjustDate: (NSCalendarDate **) date withTimeString: (NSString *) timeString diff --git a/SoObjects/SOGo/CardElement+SOGo.h b/SoObjects/SOGo/CardElement+SOGo.h index af94ebbcd..4f66e02cc 100644 --- a/SoObjects/SOGo/CardElement+SOGo.h +++ b/SoObjects/SOGo/CardElement+SOGo.h @@ -1,6 +1,6 @@ /* CardElement+SOGo.h - this file is part of SOGo * - * Copyright (C) 2014 Inverse inc. + * Copyright (C) 2014-2016 Inverse inc. * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,8 +23,13 @@ #import +@class NSCalendarDate; +@class WOContext; + @interface CardElement (SOGoExtensions) +- (NSCalendarDate *) dateFromString: (NSString *) dateString + inContext: (WOContext *) context; - (NSString *) jsonRepresentation; @end diff --git a/SoObjects/SOGo/CardElement+SOGo.m b/SoObjects/SOGo/CardElement+SOGo.m index 2ef1a741d..4770ad036 100644 --- a/SoObjects/SOGo/CardElement+SOGo.m +++ b/SoObjects/SOGo/CardElement+SOGo.m @@ -1,6 +1,6 @@ /* CardElement+SOGo.m - this file is part of SOGo * - * Copyright (C) 2014 Inverse inc. + * Copyright (C) 2014-2016 Inverse inc. * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,15 +18,54 @@ * Boston, MA 02111-1307, USA. */ +#import #import +#import +#import +#import +#import + +#import "SOGoUser.h" +#import "SOGoUserDefaults.h" #import "NSDictionary+Utilities.h" - #import "CardElement+SOGo.h" @implementation CardElement (SOGoExtensions) +/** + * From [UIxDatePicker takeValuesFromRequest:inContext:] + */ +- (NSCalendarDate *) dateFromString: (NSString *) dateString + inContext: (WOContext *) context +{ + NSInteger dateTZOffset, userTZOffset; + NSTimeZone *systemTZ, *userTZ; + SOGoUserDefaults *ud; + NSCalendarDate *date; + + date = [NSCalendarDate dateWithString: dateString + calendarFormat: @"%Y-%m-%d"]; + if (!date) + [self warnWithFormat: @"Could not parse dateString: '%@'", dateString]; + + // We must adjust the date timezone because "dateWithString:..." uses the + // system timezone, which can be different from the user's. */ + ud = [[context activeUser] userDefaults]; + systemTZ = [date timeZone]; + dateTZOffset = [systemTZ secondsFromGMTForDate: date]; + userTZ = [ud timeZone]; + userTZOffset = [userTZ secondsFromGMTForDate: date]; + if (dateTZOffset != userTZOffset) + date = [date dateByAddingYears: 0 months: 0 days: 0 + hours: 0 minutes: 0 + seconds: (dateTZOffset - userTZOffset)]; + [date setTimeZone: userTZ]; + + return date; +} + /** * Return the JSON representation of the element as a dictionary with two keys: * - type: the type of the card element, if it exists;