1998-12-02 20:14:34 +00:00
|
|
|
/* Interface for NSDateFormatter for GNUStep
|
|
|
|
Copyright (C) 1998 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
Header Written by: Camille Troillard <tuscland@wanadoo.fr>
|
|
|
|
Created: November 1998
|
|
|
|
Modified by: Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
|
|
|
|
|
|
|
This file is part of the GNUstep Base Library.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
2007-09-14 11:36:11 +00:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
1998-12-02 20:14:34 +00:00
|
|
|
License as published by the Free Software Foundation; either
|
2008-06-08 10:38:33 +00:00
|
|
|
version 2 of the License, or (at your option) any later version.
|
1998-12-02 20:14:34 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
2007-09-14 11:36:11 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
1998-12-02 20:14:34 +00:00
|
|
|
License along with this library; if not, write to the Free
|
2006-10-31 07:05:46 +00:00
|
|
|
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
Boston, MA 02111 USA.
|
1998-12-02 20:14:34 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __NSDateFormatter_h_GNUSTEP_BASE_INCLUDE
|
|
|
|
#define __NSDateFormatter_h_GNUSTEP_BASE_INCLUDE
|
2006-10-31 07:05:46 +00:00
|
|
|
#import <GNUstepBase/GSVersionMacros.h>
|
1998-12-02 20:14:34 +00:00
|
|
|
|
2006-10-31 07:05:46 +00:00
|
|
|
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
|
1998-12-02 20:14:34 +00:00
|
|
|
|
2006-10-31 07:05:46 +00:00
|
|
|
#import <Foundation/NSFormatter.h>
|
1998-12-02 20:14:34 +00:00
|
|
|
|
2011-01-22 23:26:17 +00:00
|
|
|
@class NSCalendar, NSLocale, NSArray;
|
|
|
|
|
2006-09-13 10:20:49 +00:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2011-01-22 20:36:44 +00:00
|
|
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
NSDateFormatterNoStyle = 0,
|
|
|
|
NSDateFormatterShortStyle = 1,
|
|
|
|
NSDateFormatterMediumStyle = 2,
|
|
|
|
NSDateFormatterLongStyle = 3,
|
|
|
|
NSDateFormatterFullStyle = 4
|
|
|
|
};
|
|
|
|
typedef NSUInteger NSDateFormatterStyle;
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
NSDateFormatterBehaviorDefault = 0,
|
|
|
|
NSDateFormatterBehavior10_0 = 1000,
|
2012-07-20 12:39:35 +00:00
|
|
|
NSDateFormatterBehavior10_4 = 1040
|
2011-01-22 20:36:44 +00:00
|
|
|
};
|
|
|
|
typedef NSUInteger NSDateFormatterBehavior;
|
|
|
|
#endif
|
|
|
|
|
2004-06-22 22:27:39 +00:00
|
|
|
/**
|
|
|
|
* <p>Class for generating text representations of [NSDate]s and
|
|
|
|
* [NSCalendarDate]s, and for converting strings into instances of these
|
|
|
|
* objects. Note that [NSDate] and [NSCalendarDate] do contain some
|
|
|
|
* string conversion methods, but using this class provides more control
|
|
|
|
* over conversion.</p>
|
|
|
|
* <p>See the [NSFormatter] documentation for description of the basic methods
|
|
|
|
* for formatting and parsing that are available.</p>
|
|
|
|
* <p>The basic format of a format string uses "%" codes to represent
|
|
|
|
* components of the date. Thus, for example, <code>@"%b %d, %Y"</code>
|
|
|
|
* specifies strings similar to "June 18, 1991". The full list of codes is
|
|
|
|
* as follows:</p>
|
|
|
|
* <deflist>
|
|
|
|
* <term>%%</term>
|
|
|
|
* <desc>a '%' character</desc>
|
|
|
|
* <term>%a</term>
|
|
|
|
* <desc>abbreviated weekday name</desc>
|
|
|
|
* <term>%A</term>
|
|
|
|
* <desc>full weekday name</desc>
|
|
|
|
* <term>%b</term>
|
|
|
|
* <desc>abbreviated month name</desc>
|
|
|
|
* <term>%B</term>
|
|
|
|
* <desc>full month name</desc>
|
|
|
|
* <term>%c</term>
|
|
|
|
* <desc>shorthand for "%X %x", the locale format for date and time</desc>
|
|
|
|
* <term>%d</term>
|
|
|
|
* <desc>day of the month as a decimal number (01-31)</desc>
|
|
|
|
* <term>%e</term>
|
2006-03-08 11:28:59 +00:00
|
|
|
* <desc>same as %d but does not print the leading 0 for days 1 through 9
|
|
|
|
* (unlike strftime(), does not print a leading space)</desc>
|
2004-06-22 22:27:39 +00:00
|
|
|
* <term>%F</term>
|
|
|
|
* <desc>milliseconds as a decimal number (000-999)</desc>
|
|
|
|
* <term>%H</term>
|
|
|
|
* <desc>hour based on a 24-hour clock as a decimal number (00-23)</desc>
|
|
|
|
* <term>%I</term>
|
|
|
|
* <desc>hour based on a 12-hour clock as a decimal number (01-12)</desc>
|
|
|
|
* <term>%j</term>
|
|
|
|
* <desc>day of the year as a decimal number (001-366)</desc>
|
|
|
|
* <term>%m</term>
|
|
|
|
* <desc>month as a decimal number (01-12)</desc>
|
|
|
|
* <term>%M</term>
|
|
|
|
* <desc>minute as a decimal number (00-59)</desc>
|
|
|
|
* <term>%p</term>
|
|
|
|
* <desc>AM/PM designation for the locale</desc>
|
|
|
|
* <term>%S</term>
|
|
|
|
* <desc>second as a decimal number (00-59)</desc>
|
|
|
|
* <term>%w</term>
|
|
|
|
* <desc>weekday as a decimal number (0-6), where Sunday is 0</desc>
|
|
|
|
* <term>%x</term>
|
2006-03-08 11:28:59 +00:00
|
|
|
* <desc>date using the date representation for the locale, including the
|
|
|
|
* time zone (produces different results from strftime())</desc>
|
2004-06-22 22:27:39 +00:00
|
|
|
* <term>%X</term>
|
2006-03-08 11:28:59 +00:00
|
|
|
* <desc>time using the time representation for the locale (produces
|
|
|
|
* different results from strftime())</desc>
|
2004-06-22 22:27:39 +00:00
|
|
|
* <term>%y</term>
|
|
|
|
* <desc>year without century (00-99)</desc>
|
|
|
|
* <term>%Y</term>
|
|
|
|
* <desc>year with century (such as 1990)</desc>
|
|
|
|
* <term>%Z</term>
|
2006-03-08 11:28:59 +00:00
|
|
|
* <desc>time zone name (such as Pacific Daylight Time; produces different
|
|
|
|
* results from strftime())</desc>
|
2004-06-22 22:27:39 +00:00
|
|
|
* <term>%z</term>
|
|
|
|
* <desc>time zone offset in hours and minutes from GMT (HHMM)</desc>
|
|
|
|
* </deflist>
|
|
|
|
*/
|
1998-12-02 20:14:34 +00:00
|
|
|
@interface NSDateFormatter : NSFormatter <NSCoding, NSCopying>
|
|
|
|
{
|
2010-02-14 10:48:10 +00:00
|
|
|
#if GS_EXPOSE(NSDateFormatter)
|
1999-09-16 07:21:34 +00:00
|
|
|
NSString *_dateFormat;
|
|
|
|
BOOL _allowsNaturalLanguage;
|
2010-11-23 13:20:34 +00:00
|
|
|
#endif
|
2011-02-16 05:49:45 +00:00
|
|
|
#if GS_NONFRAGILE
|
|
|
|
# if defined(GS_NSDateFormatter_IVARS)
|
|
|
|
@public
|
|
|
|
GS_NSDateFormatter_IVARS;
|
|
|
|
# endif
|
|
|
|
#else
|
2011-02-14 06:37:45 +00:00
|
|
|
/* Pointer to private additional data used to avoid breaking ABI
|
|
|
|
* when we don't have the non-fragile ABI available.
|
2011-02-16 05:49:45 +00:00
|
|
|
* Use this mechanism rather than changing the instance variable
|
|
|
|
* layout (see Source/GSInternal.h for details).
|
2011-02-14 06:37:45 +00:00
|
|
|
*/
|
2011-03-05 18:12:55 +00:00
|
|
|
@private id _internal GS_UNUSED_IVAR;
|
2011-02-14 06:37:45 +00:00
|
|
|
#endif
|
1998-12-02 20:14:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Initializing an NSDateFormatter */
|
2004-06-22 22:27:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize with given specifier string format. See class description for
|
|
|
|
* how to specify a format string. If flag is YES, string-to-object
|
|
|
|
* conversion will attempt to process strings as natural language dates, such
|
|
|
|
* as "yesterday", or "first Tuesday of next month" if straight format-based
|
|
|
|
* conversion fails.
|
|
|
|
*/
|
1998-12-02 20:14:34 +00:00
|
|
|
- (id) initWithDateFormat: (NSString *)format
|
|
|
|
allowNaturalLanguage: (BOOL)flag;
|
|
|
|
|
2004-06-22 22:27:39 +00:00
|
|
|
|
1998-12-02 20:14:34 +00:00
|
|
|
/* Determining Attributes */
|
2004-06-22 22:27:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether initialized to support natural language formatting. If
|
|
|
|
* YES, string-to-object conversion will attempt to process strings as
|
|
|
|
* natural language dates, such as "yesterday", or "first Tuesday of next
|
|
|
|
* month" if straight format-based conversion fails.
|
|
|
|
*/
|
1998-12-02 20:14:34 +00:00
|
|
|
- (BOOL) allowsNaturalLanguage;
|
2004-06-22 22:27:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns format string initialized with, specifying how dates are formatted,
|
|
|
|
* for object-to-string conversion, and how they are parsed, for
|
|
|
|
* string-to-object conversion. For example, <code>@"%b %d, %Y"</code>
|
|
|
|
* specifies strings similar to "June 18, 1991".
|
|
|
|
*/
|
1998-12-02 20:14:34 +00:00
|
|
|
- (NSString *) dateFormat;
|
2011-01-22 20:36:44 +00:00
|
|
|
|
|
|
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
|
|
|
|
+ (NSDateFormatterBehavior) defaultFormatterBehavior;
|
|
|
|
+ (void) setDefaultFormatterBehavior: (NSDateFormatterBehavior) behavior;
|
|
|
|
|
|
|
|
- (NSDateFormatterBehavior) formatterBehavior;
|
|
|
|
- (void) setFormatterBehavior: (NSDateFormatterBehavior) behavior;
|
|
|
|
- (BOOL) generatesCalendarDates;
|
|
|
|
- (void) setGeneratesCalendarDates: (BOOL) flag;
|
|
|
|
- (BOOL) isLenient;
|
|
|
|
- (void) setLenient: (BOOL) flag;
|
|
|
|
|
|
|
|
- (NSDate *) dateFromString: (NSString *) string;
|
|
|
|
- (NSString *) stringFromDate: (NSDate *) date;
|
|
|
|
- (BOOL) getObjectValue: (out id *) obj
|
|
|
|
forString: (NSString *) string
|
|
|
|
range: (inout NSRange *) range
|
|
|
|
error: (out NSError **) error;
|
|
|
|
|
|
|
|
- (void) setDateFormat: (NSString *) string;
|
|
|
|
- (NSDateFormatterStyle) dateStyle;
|
|
|
|
- (void) setDateStyle: (NSDateFormatterStyle) style;
|
|
|
|
- (NSDateFormatterStyle) timeStyle;
|
|
|
|
- (void) setTimeStyle: (NSDateFormatterStyle) style;
|
|
|
|
|
|
|
|
- (NSCalendar *) calendar;
|
|
|
|
- (void) setCalendar: (NSCalendar *) calendar;
|
|
|
|
- (NSDate *) defaultDate;
|
|
|
|
- (void) setDefaultDate: (NSDate *) date;
|
|
|
|
- (NSLocale *) locale;
|
|
|
|
- (void) setLocale: (NSLocale *) locale;
|
|
|
|
- (NSTimeZone *) timeZone;
|
|
|
|
- (void) setTimeZone: (NSTimeZone *) tz;
|
|
|
|
- (NSDate *) twoDigitStartDate;
|
|
|
|
- (void) setTwoDigitStartDate: (NSDate *) date;
|
|
|
|
|
|
|
|
- (NSString *) AMSymbol;
|
|
|
|
- (void) setAMSymbol: (NSString *) string;
|
|
|
|
- (NSString *) PMSymbol;
|
|
|
|
- (void) setPMSymbol: (NSString *) string;
|
|
|
|
|
|
|
|
- (NSArray *) weekdaySymbols;
|
2011-01-23 04:54:30 +00:00
|
|
|
- (void) setWeekdaySymbols: (NSArray *) array;
|
2011-01-22 20:36:44 +00:00
|
|
|
- (NSArray *) shortWeekdaySymbols;
|
|
|
|
- (void) setShortWeekdaySymbols: (NSArray *) array;
|
|
|
|
|
|
|
|
- (NSArray *) monthSymbols;
|
|
|
|
- (void) setMonthSymbols: (NSArray *) array;
|
|
|
|
- (NSArray *) shortMonthSymbols;
|
|
|
|
- (void) setShortMonthSymbols: (NSArray *) array;
|
|
|
|
|
|
|
|
- (NSArray *) eraSymbols;
|
|
|
|
- (void) setEraSymbols: (NSArray *) array;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)
|
|
|
|
- (NSDate *) gregorianStartDate;
|
|
|
|
- (void) setGregorianStartDate: (NSDate *) date;
|
|
|
|
|
|
|
|
- (NSArray *) longEraSymbols;
|
|
|
|
- (void) setLongEraSymbols: (NSArray *) array;
|
|
|
|
|
|
|
|
- (NSArray *) quarterSymbols;
|
|
|
|
- (void) setQuarterSymbols: (NSArray *) array;
|
|
|
|
- (NSArray *) shortQuarterSymbols;
|
|
|
|
- (void) setShortQuarterSymbols: (NSArray *) array;
|
|
|
|
- (NSArray *) standaloneQuarterSymbols;
|
|
|
|
- (void) setStandaloneQuarterSymbols: (NSArray *) array;
|
|
|
|
- (NSArray *) shortStandaloneQuarterSymbols;
|
|
|
|
- (void) setShortStandaloneQuarterSymbols: (NSArray *) array;
|
|
|
|
|
|
|
|
- (NSArray *) shortStandaloneMonthSymbols;
|
|
|
|
- (void) setShortStandaloneMonthSymbols: (NSArray *) array;
|
|
|
|
- (NSArray *) standaloneMonthSymbols;
|
|
|
|
- (void) setStandaloneMonthSymbols: (NSArray *) array;
|
|
|
|
- (NSArray *) veryShortMonthSymbols;
|
|
|
|
- (void) setVeryShortMonthSymbols: (NSArray *) array;
|
|
|
|
- (NSArray *) veryShortStandaloneMonthSymbols;
|
|
|
|
- (void) setVeryShortStandaloneMonthSymbols: (NSArray *) array;
|
|
|
|
|
2011-01-22 23:26:17 +00:00
|
|
|
- (NSArray *) shortStandaloneWeekdaySymbols;
|
2011-01-22 20:36:44 +00:00
|
|
|
- (void) setShortStandaloneWeekdaySymbols: (NSArray *) array;
|
|
|
|
- (NSArray *) standaloneWeekdaySymbols;
|
|
|
|
- (void) setStandaloneWeekdaySymbols: (NSArray *) array;
|
|
|
|
- (NSArray *) veryShortWeekdaySymbols;
|
|
|
|
- (void) setVeryShortWeekdaySymbols: (NSArray *) array;
|
|
|
|
- (NSArray *) veryShortStandaloneWeekdaySymbols;
|
|
|
|
- (void) setVeryShortStandaloneWeekdaySymbols: (NSArray *) array;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
|
|
|
|
+ (NSString *) localizedStringFromDate: (NSDate *) date
|
|
|
|
dateStyle: (NSDateFormatterStyle) dateStyle
|
|
|
|
timeStyle: (NSDateFormatterStyle) timeStyle;
|
2011-02-09 13:11:42 +00:00
|
|
|
+ (NSString *) dateFormatFromTemplate: (NSString *) aTemplate
|
2011-01-22 20:36:44 +00:00
|
|
|
options: (NSUInteger) opts
|
|
|
|
locale: (NSLocale *) locale;
|
|
|
|
|
|
|
|
- (BOOL) doesRelativeDateFormatting;
|
|
|
|
- (void) setDoesRelativeDateFormatting: (BOOL) flag;
|
|
|
|
#endif
|
1998-12-02 20:14:34 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2006-09-13 10:20:49 +00:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1998-12-02 20:14:34 +00:00
|
|
|
#endif /* _NSDateFormatter_h_GNUSTEP_BASE_INCLUDE */
|