mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Add new, completely empty and useless NSCalendar class.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@31735 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
168e5962a9
commit
d150a82634
6 changed files with 482 additions and 1 deletions
|
@ -1,3 +1,12 @@
|
|||
2010-12-14 Stefan Bidigaray <stefanbidi@gmail.com>
|
||||
|
||||
* Headers/Foundation/Foundation.h:
|
||||
* Source/GNUmakefile: Include NSCalendar.
|
||||
* configure.ac: Check for unicode/ucal.h.
|
||||
* Headers/Foundation/NSCalendar.h:
|
||||
* Source/NSCalendar.m: Add completely empty NSCalendar and
|
||||
NSDateCompoennts classes.
|
||||
|
||||
2010-12-14 Stefan Bidigaray <stefanbidi@gmail.com>
|
||||
|
||||
* Source/NSLocale.m: Initialize _components before using it and initilize
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#import <Foundation/NSBundle.h>
|
||||
#import <Foundation/NSByteOrder.h>
|
||||
#import <Foundation/NSCache.h>
|
||||
#import <Foundation/NSCalendar.h>
|
||||
#import <Foundation/NSCalendarDate.h>
|
||||
#import <Foundation/NSCharacterSet.h>
|
||||
#import <Foundation/NSClassDescription.h>
|
||||
|
|
177
Headers/Foundation/NSCalendar.h
Normal file
177
Headers/Foundation/NSCalendar.h
Normal file
|
@ -0,0 +1,177 @@
|
|||
/* NSCalendar.h
|
||||
|
||||
Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Stefan Bidigaray
|
||||
Date: December, 2010
|
||||
|
||||
This library 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 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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 this library; see the file COPYING.LIB.
|
||||
If not, see <http://www.gnu.org/licenses/> or write to the
|
||||
Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __NSCalendar_h_GNUSTEP_BASE_INCLUDE
|
||||
#define __NSCalendar_h_GNUSTEP_BASE_INCLUDE
|
||||
|
||||
#import <GNUstepBase/GSVersionMacros.h>
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
|
||||
|
||||
#include <Foundation/NSObject.h>
|
||||
|
||||
@class NSDate;
|
||||
@class NSLocale;
|
||||
@class NSString;
|
||||
@class NSTimeZone;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef NSUInteger NSCalendarUnit;
|
||||
enum
|
||||
{
|
||||
NSEraCalendarUnit = (1UL << 1),
|
||||
NSYearCalendarUnit = (1UL << 2),
|
||||
NSMonthCalendarUnit = (1UL << 3),
|
||||
NSDayCalendarUnit = (1UL << 4),
|
||||
NSHourCalendarUnit = (1UL << 5),
|
||||
NSMinuteCalendarUnit = (1UL << 6),
|
||||
NSSecondCalendarUnit = (1UL << 7),
|
||||
NSWeekCalendarUnit = (1UL << 8),
|
||||
NSWeekdayCalendarUnit = (1UL << 9),
|
||||
NSWeekdayOrdinalCalendarUnit = (1UL << 10),
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
|
||||
NSQuarterCalendarUnit = (1UL << 11)
|
||||
#endif
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
NSWrapCalendarComponents = (1UL << 0)
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
NSUndefinedDateComponent = 0x7fffffff
|
||||
};
|
||||
|
||||
|
||||
|
||||
@interface NSDateComponents : NSObject
|
||||
{
|
||||
NSInteger _era;
|
||||
NSInteger _year;
|
||||
NSInteger _month;
|
||||
NSInteger _day;
|
||||
NSInteger _hour;
|
||||
NSInteger _minute;
|
||||
NSInteger _second;
|
||||
NSInteger _week;
|
||||
NSInteger _weekday;
|
||||
NSInteger _weekdayOrdinal;
|
||||
NSInteger _quarter;
|
||||
}
|
||||
|
||||
- (NSInteger) day;
|
||||
- (NSInteger) era;
|
||||
- (NSInteger) hour;
|
||||
- (NSInteger) minute;
|
||||
- (NSInteger) month;
|
||||
- (NSInteger) second;
|
||||
- (NSInteger) week;
|
||||
- (NSInteger) weekday;
|
||||
- (NSInteger) weekdayOrdinal;
|
||||
- (NSInteger) year;
|
||||
|
||||
- (void) setDay: (NSInteger) v;
|
||||
- (void) setEra: (NSInteger) v;
|
||||
- (void) setHour: (NSInteger) v;
|
||||
- (void) setMinute: (NSInteger) v;
|
||||
- (void) setMonth: (NSInteger) v;
|
||||
- (void) setQuarter: (NSInteger) v;
|
||||
- (void) setSecond: (NSInteger) v;
|
||||
- (void) setWeek: (NSInteger) v;
|
||||
- (void) setWeekday: (NSInteger) v;
|
||||
- (void) setWeekdayOrdinal: (NSInteger) v;
|
||||
- (void) setYear: (NSInteger) v;
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
|
||||
- (NSInteger) quarter;
|
||||
- (void) setQuarter: (NSInteger) v;
|
||||
#endif
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@interface NSCalendar : NSObject
|
||||
{
|
||||
NSString *_identifier;
|
||||
NSLocale *_locale;
|
||||
NSTimeZone *_tz;
|
||||
void *_calendar;
|
||||
}
|
||||
|
||||
+ (id) currentCalendar;
|
||||
|
||||
- (id) initWithCalendarIdentifier: (NSString *) string;
|
||||
- (NSString *) calendarIdentifier;
|
||||
|
||||
- (NSDateComponents *) components: (NSUInteger) unitFlags
|
||||
fromDate: (NSDate *) date;
|
||||
- (NSDateComponents *) components: (NSUInteger) unitFlags
|
||||
fromDate: (NSDate *) startingDate
|
||||
toDate: (NSDate *) resultDate
|
||||
options: (NSUInteger) opts;
|
||||
- (NSDate *) dateByAddingComponents: (NSDateComponents *) comps
|
||||
toDate: (NSDate *) date
|
||||
options: (NSUInteger) opts;
|
||||
- (NSDate *) dateFromComponents: (NSDateComponents *) comps;
|
||||
|
||||
- (NSLocale *) locale;
|
||||
- (void)setLocale: (NSLocale *) locale;
|
||||
- (NSUInteger) firstWeekday;
|
||||
- (void) setFirstWeekday: (NSUInteger) weekday;
|
||||
- (NSUInteger) minimumDayInFirstWeek;
|
||||
- (void) setMinimumDaysInFirstWeek: (NSUInteger) mdw;
|
||||
- (NSTimeZone *) timeZone;
|
||||
- (void) setTimeZone: (NSTimeZone *) tz;
|
||||
|
||||
- (NSRange) maximumRangeOfUnit: (NSCalendarUnit) unit;
|
||||
- (NSRange) minimumRangeofUnit: (NSCalendarUnit) unit;
|
||||
- (NSUInteger) ordinalityOfUnit: (NSCalendarUnit) smaller
|
||||
inUnit: (NSCalendarUnit) larger
|
||||
forDate: (NSDate *) date;
|
||||
- (NSRange) rangeOfUnit: (NSCalendarUnit) smaller
|
||||
inUnit: (NSCalendarUnit) larger
|
||||
forDate: (NSDate *) date;
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)
|
||||
+ (id) autoupdatingCurrentCalendar;
|
||||
|
||||
- (BOOL) rangeOfUnit: (NSCalendarUnit) unit
|
||||
startDate: (NSDate **) datep
|
||||
interval: (NSTimeInterval *)tip
|
||||
forDate:(NSDate *)date;
|
||||
#endif
|
||||
@end
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST) */
|
||||
|
||||
#endif /* __NSCalendar_h_GNUSTEP_BASE_INCLUDE */
|
|
@ -172,6 +172,7 @@ NSAutoreleasePool.m \
|
|||
NSBundle.m \
|
||||
NSCache.m \
|
||||
NSCachedURLResponse.m \
|
||||
NSCalendar.m \
|
||||
NSCalendarDate.m \
|
||||
NSCallBacks.m \
|
||||
NSCharacterSet.m \
|
||||
|
|
293
Source/NSCalendar.m
Normal file
293
Source/NSCalendar.m
Normal file
|
@ -0,0 +1,293 @@
|
|||
/* NSCalendar.m
|
||||
|
||||
Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Stefan Bidigaray
|
||||
Date: December, 2010
|
||||
|
||||
This library 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 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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 this library; see the file COPYING.LIB.
|
||||
If not, see <http://www.gnu.org/licenses/> or write to the
|
||||
Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#import "common.h"
|
||||
#import "Foundation/NSCalendar.h"
|
||||
#import "Foundation/NSDate.h"
|
||||
#import "Foundation/NSLocale.h"
|
||||
#import "Foundation/NSString.h"
|
||||
#import "Foundation/NSTimeZone.h"
|
||||
|
||||
#if defined(HAVE_UNICODE_UCAL_H)
|
||||
#include <unicode/ucal.h>
|
||||
#endif
|
||||
|
||||
@implementation NSCalendar
|
||||
|
||||
+ (id) currentCalendar
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (id) initWithCalendarIdentifier: (NSString *) string
|
||||
{
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSString *) calendarIdentifier
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
||||
- (NSDateComponents *) components: (NSUInteger) unitFlags
|
||||
fromDate: (NSDate *) date
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSDateComponents *) components: (NSUInteger) unitFlags
|
||||
fromDate: (NSDate *) startingDate
|
||||
toDate: (NSDate *) resultDate
|
||||
options: (NSUInteger) opts
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSDate *) dateByAddingComponents: (NSDateComponents *) comps
|
||||
toDate: (NSDate *) date
|
||||
options: (NSUInteger) opts
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSDate *) dateFromComponents: (NSDateComponents *) comps
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSLocale *) locale
|
||||
{
|
||||
return _locale;
|
||||
}
|
||||
|
||||
- (void)setLocale: (NSLocale *) locale
|
||||
{
|
||||
_locale = locale;
|
||||
}
|
||||
|
||||
- (NSUInteger) firstWeekday
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (void) setFirstWeekday: (NSUInteger) weekday
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
- (NSUInteger) minimumDayInFirstWeek
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (void) setMinimumDaysInFirstWeek: (NSUInteger) mdw
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
- (NSTimeZone *) timeZone
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void) setTimeZone: (NSTimeZone *) tz
|
||||
{
|
||||
_tz = tz;
|
||||
}
|
||||
|
||||
|
||||
- (NSRange) maximumRangeOfUnit: (NSCalendarUnit) unit
|
||||
{
|
||||
return NSMakeRange (0, 0);
|
||||
}
|
||||
|
||||
- (NSRange) minimumRangeofUnit: (NSCalendarUnit) unit
|
||||
{
|
||||
return NSMakeRange (0, 0);
|
||||
}
|
||||
|
||||
- (NSUInteger) ordinalityOfUnit: (NSCalendarUnit) smaller
|
||||
inUnit: (NSCalendarUnit) larger
|
||||
forDate: (NSDate *) date
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (NSRange) rangeOfUnit: (NSCalendarUnit) smaller
|
||||
inUnit: (NSCalendarUnit) larger
|
||||
forDate: (NSDate *) date
|
||||
{
|
||||
return NSMakeRange (0, 0);
|
||||
}
|
||||
|
||||
+ (id) autoupdatingCurrentCalendar
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
||||
- (BOOL) rangeOfUnit: (NSCalendarUnit) unit
|
||||
startDate: (NSDate **) datep
|
||||
interval: (NSTimeInterval *)tip
|
||||
forDate:(NSDate *)date
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@implementation NSDateComponents
|
||||
|
||||
- (id) init
|
||||
{
|
||||
_era = NSUndefinedDateComponent;
|
||||
_year = NSUndefinedDateComponent;
|
||||
_month = NSUndefinedDateComponent;
|
||||
_day = NSUndefinedDateComponent;
|
||||
_hour = NSUndefinedDateComponent;
|
||||
_minute = NSUndefinedDateComponent;
|
||||
_second = NSUndefinedDateComponent;
|
||||
_week = NSUndefinedDateComponent;
|
||||
_weekday = NSUndefinedDateComponent;
|
||||
_weekdayOrdinal = NSUndefinedDateComponent;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSInteger) day
|
||||
{
|
||||
return _day;
|
||||
}
|
||||
|
||||
- (NSInteger) era
|
||||
{
|
||||
return _era;
|
||||
}
|
||||
|
||||
- (NSInteger) hour
|
||||
{
|
||||
return _hour;
|
||||
}
|
||||
|
||||
- (NSInteger) minute
|
||||
{
|
||||
return _minute;
|
||||
}
|
||||
|
||||
- (NSInteger) month
|
||||
{
|
||||
return _month;
|
||||
}
|
||||
|
||||
- (NSInteger) quarter
|
||||
{
|
||||
return _quarter;
|
||||
}
|
||||
|
||||
- (NSInteger) second
|
||||
{
|
||||
return _second;
|
||||
}
|
||||
|
||||
- (NSInteger) week
|
||||
{
|
||||
return _week;
|
||||
}
|
||||
|
||||
- (NSInteger) weekday
|
||||
{
|
||||
return _weekday;
|
||||
}
|
||||
|
||||
- (NSInteger) weekdayOrdinal
|
||||
{
|
||||
return _weekdayOrdinal;
|
||||
}
|
||||
|
||||
- (NSInteger) year
|
||||
{
|
||||
return _year;
|
||||
}
|
||||
|
||||
|
||||
|
||||
- (void) setDay: (NSInteger) v
|
||||
{
|
||||
_day = v;
|
||||
}
|
||||
|
||||
- (void) setEra: (NSInteger) v
|
||||
{
|
||||
_era = v;
|
||||
}
|
||||
|
||||
- (void) setHour: (NSInteger) v
|
||||
{
|
||||
_hour = v;
|
||||
}
|
||||
|
||||
- (void) setMinute: (NSInteger) v
|
||||
{
|
||||
_minute = v;
|
||||
}
|
||||
|
||||
- (void) setMonth: (NSInteger) v
|
||||
{
|
||||
_month = v;
|
||||
}
|
||||
|
||||
- (void) setQuarter: (NSInteger) v
|
||||
{
|
||||
_quarter = v;
|
||||
}
|
||||
|
||||
- (void) setSecond: (NSInteger) v
|
||||
{
|
||||
_second = v;
|
||||
}
|
||||
|
||||
- (void) setWeek: (NSInteger) v
|
||||
{
|
||||
_week = v;
|
||||
}
|
||||
|
||||
- (void) setWeekday: (NSInteger) v
|
||||
{
|
||||
_weekday = v;
|
||||
}
|
||||
|
||||
- (void) setWeekdayOrdinal: (NSInteger) v
|
||||
{
|
||||
_weekdayOrdinal = v;
|
||||
}
|
||||
|
||||
- (void) setYear: (NSInteger) v
|
||||
{
|
||||
_year = v;
|
||||
}
|
||||
|
||||
@end
|
|
@ -2648,7 +2648,7 @@ if test $enable_icu = yes; then
|
|||
AC_CHECK_ICU(4.0, have_icu=yes, have_icu=no)
|
||||
if test "$have_icu" = "yes"; then
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_CHECK_HEADERS(unicode/uloc.h unicode/ulocdata.h unicode/ucurr.h unicode/uregex.h)
|
||||
AC_CHECK_HEADERS(unicode/uloc.h unicode/ulocdata.h unicode/ucurr.h unicode/uregex.h unicode/ucal.h)
|
||||
LIBS="$LIBS $ICU_LIBS"
|
||||
HAVE_ICU=1
|
||||
AC_DEFINE(HAVE_ICU,1,
|
||||
|
|
Loading…
Reference in a new issue