fix(calendar): adjust invalid dates when importing a vEvent

Fixes #4845
This commit is contained in:
Francis Lachapelle
2019-11-27 17:00:28 -05:00
parent f872dc52c6
commit 3bb40e4024
6 changed files with 207 additions and 201 deletions
+21 -19
View File
@@ -1,31 +1,32 @@
/* NSCalendarDate+SOGo.h - this file is part of SOGo
Copyright (C) 2000-2004 SKYRIX Software AG
This file is part of OGo
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.
*/
*
* Copyright (C) 2019 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
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This file 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef NSCALENDARDATE_SCHEDULER_H
#define NSCALENDARDATE_SCHEDULER_H
#import <Foundation/NSCalendarDate.h>
@class NSCalendarDate;
@class NSString;
@class NSTimeZone;
@class SOGoUser;
@interface NSCalendarDate (SOGoExtensions)
@@ -34,6 +35,7 @@
inTimeZone: (NSTimeZone *) timeZone;
- (BOOL) isDateInSameMonth: (NSCalendarDate *) _other;
- (NSCalendarDate *) beginOfDayForUser: (SOGoUser *) user;
- (NSString *) shortDateString;
- (NSString *) rfc822DateString;
+41 -19
View File
@@ -1,29 +1,31 @@
/* NSCalendarDate+SOGo.m - this file is part of SOGo
Copyright (C) 2000-2004 SKYRIX Software AG
This file is part of OGo
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.
*/
*
* Copyright (C) 2019 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
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This file 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#import <Foundation/NSTimeZone.h>
#import <Foundation/NSValue.h>
#import <NGExtensions/NSCalendarDate+misc.h>
#import <SOGo/SOGoUser.h>
#import <SOGo/SOGoUserDefaults.h>
#import "NSCalendarDate+SOGo.h"
static NSString *rfc822Days[] = {@"Sun", @"Mon", @"Tue", @"Wed", @"Thu",
@@ -96,6 +98,26 @@ static NSString *rfc822Months[] = {@"", @"Jan", @"Feb", @"Mar", @"Apr",
return str;
}
- (NSCalendarDate *) beginOfDayForUser: (SOGoUser *) user
{
NSCalendarDate *date;
NSTimeZone *timeZone;
SOGoUserDefaults *ud;
ud = [user userDefaults];
timeZone = [ud timeZone];
[self setTimeZone: timeZone];
date = [self beginOfDay];
date = [date addYear: 0
month: 0
day: 0
hour: 0 - [date hourOfDay] + [ud dayStartHour]
minute: 0 - [date minuteOfHour]
second: 0];
return date;
}
- (NSString *) rfc822DateString
{
int timeZoneShift, tzSeconds;