Up
Authors
- Richard Frith-Macdonald (
richard@brainstorm.co.uk
)
-
Version: 38555
Date: 2015-05-26 06:10:20 -0600 (Tue, 26 May 2015)
Copyright: (C) 1998 Free Software Foundation, Inc.
- Declared in:
- Foundation/NSDateFormatter.h
- Conforms to:
- NSCoding
- NSCopying
Availability: MacOS-X 10.0.0
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.
See the
NSFormatter
documentation for description of the basic methods for formatting and parsing that are available.
The basic format of a format string uses "%"
codes to represent components of the date.
Thus, for example,
@"%b %d, %Y"
specifies
strings similar to "June 18, 1991". The
full list of codes is as follows:
- %%
-
a '%' character
- %a
-
abbreviated weekday name
- %A
-
full weekday name
- %b
-
abbreviated month name
- %B
-
full month name
- %c
-
shorthand for "%X %x", the locale
format for date and time
- %d
-
day of the month as a decimal number
(01-31)
- %e
-
same as %d but does not print the leading
0 for days 1 through 9 (unlike
strftime()
, does not print a leading space)
- %F
-
milliseconds as a decimal number
(000-999)
- %H
-
hour based on a 24-hour clock as a decimal
number (00-23)
- %I
-
hour based on a 12-hour clock as a decimal
number (01-12)
- %j
-
day of the year as a decimal number
(001-366)
- %m
-
month as a decimal number (01-12)
- %M
-
minute as a decimal number (00-59)
- %p
-
AM/PM designation for the locale
- %S
-
second as a decimal number (00-59)
- %w
-
weekday as a decimal number (0-6),
where Sunday is 0
- %x
-
date using the date representation for the
locale, including the time zone
(produces different results from
strftime())
- %X
-
time using the time representation for the
locale (produces different results from
strftime())
- %y
-
year without century (00-99)
- %Y
-
year with century (such as 1990)
- %Z
-
time zone name (such as Pacific Daylight
Time; produces different results from
strftime())
- %z
-
time zone offset in hours and minutes from
GMT (HHMM)
Instance Variables
Method summary
+ (
NSString*)
dateFormatFromTemplate: (
NSString*)aTemplate
options: (
NSUInteger)opts
locale: (NSLocale*)locale;
Availability: MacOS-X 10.6.0
Description forthcoming.
+ (void)
setDefaultFormatterBehavior: (
NSDateFormatterBehavior)behavior;
Availability: MacOS-X 10.4.0
Description forthcoming.
- (
NSString*)
AMSymbol;
Availability: MacOS-X 10.4.0
Description forthcoming.
- (
NSString*)
PMSymbol;
Availability: MacOS-X 10.4.0
Description forthcoming.
- (BOOL)
allowsNaturalLanguage;
Availability: MacOS-X 10.0.0
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.
- (NSCalendar*)
calendar;
Availability: MacOS-X 10.4.0
Description forthcoming.
- (
NSString*)
dateFormat;
Availability: MacOS-X 10.0.0
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,
@"%b %d, %Y"
specifies strings similar
to "June 18, 1991".
- (
NSDate*)
dateFromString: (
NSString*)string;
Availability: MacOS-X 10.4.0
Description forthcoming.
- (
NSDate*)
defaultDate;
Availability: MacOS-X 10.4.0
Description forthcoming.
- (BOOL)
doesRelativeDateFormatting;
Availability: MacOS-X 10.6.0
Description forthcoming.
- (
NSArray*)
eraSymbols;
Availability: MacOS-X 10.4.0
Description forthcoming.
- (BOOL)
generatesCalendarDates;
Availability: MacOS-X 10.4.0
Description forthcoming.
- (BOOL)
getObjectValue: (out id*)obj
forString: (
NSString*)string
range: (inout
NSRange*)range
error: (out
NSError**)error;
Availability: MacOS-X 10.4.0
Description forthcoming.
- (
NSDate*)
gregorianStartDate;
Availability: MacOS-X 10.5.0
Description forthcoming.
- (id)
initWithDateFormat: (
NSString*)format
allowNaturalLanguage: (BOOL)flag;
Availability: MacOS-X 10.0.0
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.
- (BOOL)
isLenient;
Availability: MacOS-X 10.4.0
Description forthcoming.
- (NSLocale*)
locale;
Availability: MacOS-X 10.4.0
Description forthcoming.
- (
NSArray*)
longEraSymbols;
Availability: MacOS-X 10.5.0
Description forthcoming.
- (
NSArray*)
monthSymbols;
Availability: MacOS-X 10.4.0
Description forthcoming.
- (
NSArray*)
quarterSymbols;
Availability: MacOS-X 10.5.0
Description forthcoming.
- (void)
setAMSymbol: (
NSString*)string;
Availability: MacOS-X 10.4.0
Description forthcoming.
- (void)
setCalendar: (NSCalendar*)calendar;
Availability: MacOS-X 10.4.0
Description forthcoming.
- (void)
setDateFormat: (
NSString*)string;
Availability: MacOS-X 10.4.0
Description forthcoming.
- (void)
setDateStyle: (
NSDateFormatterStyle)style;
Availability: MacOS-X 10.4.0
Description forthcoming.
- (void)
setDefaultDate: (
NSDate*)date;
Availability: MacOS-X 10.4.0
Description forthcoming.
- (void)
setDoesRelativeDateFormatting: (BOOL)flag;
Availability: MacOS-X 10.6.0
Description forthcoming.
- (void)
setEraSymbols: (
NSArray*)array;
Availability: MacOS-X 10.4.0
Description forthcoming.
- (void)
setFormatterBehavior: (
NSDateFormatterBehavior)behavior;
Availability: MacOS-X 10.4.0
Description forthcoming.
- (void)
setGeneratesCalendarDates: (BOOL)flag;
Availability: MacOS-X 10.4.0
Description forthcoming.
- (void)
setGregorianStartDate: (
NSDate*)date;
Availability: MacOS-X 10.5.0
Description forthcoming.
- (void)
setLenient: (BOOL)flag;
Availability: MacOS-X 10.4.0
Description forthcoming.
- (void)
setLocale: (NSLocale*)locale;
Availability: MacOS-X 10.4.0
Description forthcoming.
- (void)
setLongEraSymbols: (
NSArray*)array;
Availability: MacOS-X 10.5.0
Description forthcoming.
- (void)
setMonthSymbols: (
NSArray*)array;
Availability: MacOS-X 10.4.0
Description forthcoming.
- (void)
setPMSymbol: (
NSString*)string;
Availability: MacOS-X 10.4.0
Description forthcoming.
- (void)
setQuarterSymbols: (
NSArray*)array;
Availability: MacOS-X 10.5.0
Description forthcoming.
- (void)
setShortMonthSymbols: (
NSArray*)array;
Availability: MacOS-X 10.4.0
Description forthcoming.
- (void)
setShortQuarterSymbols: (
NSArray*)array;
Availability: MacOS-X 10.5.0
Description forthcoming.
- (void)
setShortStandaloneMonthSymbols: (
NSArray*)array;
Availability: MacOS-X 10.5.0
Description forthcoming.
- (void)
setShortStandaloneQuarterSymbols: (
NSArray*)array;
Availability: MacOS-X 10.5.0
Description forthcoming.
- (void)
setShortStandaloneWeekdaySymbols: (
NSArray*)array;
Availability: MacOS-X 10.5.0
Description forthcoming.
- (void)
setShortWeekdaySymbols: (
NSArray*)array;
Availability: MacOS-X 10.4.0
Description forthcoming.
- (void)
setStandaloneMonthSymbols: (
NSArray*)array;
Availability: MacOS-X 10.5.0
Description forthcoming.
- (void)
setStandaloneQuarterSymbols: (
NSArray*)array;
Availability: MacOS-X 10.5.0
Description forthcoming.
- (void)
setStandaloneWeekdaySymbols: (
NSArray*)array;
Availability: MacOS-X 10.5.0
Description forthcoming.
- (void)
setTimeStyle: (
NSDateFormatterStyle)style;
Availability: MacOS-X 10.4.0
Description forthcoming.
- (void)
setTimeZone: (
NSTimeZone*)tz;
Availability: MacOS-X 10.4.0
Description forthcoming.
- (void)
setTwoDigitStartDate: (
NSDate*)date;
Availability: MacOS-X 10.4.0
Description forthcoming.
- (void)
setVeryShortMonthSymbols: (
NSArray*)array;
Availability: MacOS-X 10.5.0
Description forthcoming.
- (void)
setVeryShortStandaloneMonthSymbols: (
NSArray*)array;
Availability: MacOS-X 10.5.0
Description forthcoming.
- (void)
setVeryShortStandaloneWeekdaySymbols: (
NSArray*)array;
Availability: MacOS-X 10.5.0
Description forthcoming.
- (void)
setVeryShortWeekdaySymbols: (
NSArray*)array;
Availability: MacOS-X 10.5.0
Description forthcoming.
- (void)
setWeekdaySymbols: (
NSArray*)array;
Availability: MacOS-X 10.4.0
Description forthcoming.
- (
NSArray*)
shortMonthSymbols;
Availability: MacOS-X 10.4.0
Description forthcoming.
- (
NSArray*)
shortQuarterSymbols;
Availability: MacOS-X 10.5.0
Description forthcoming.
- (
NSArray*)
shortStandaloneMonthSymbols;
Availability: MacOS-X 10.5.0
Description forthcoming.
- (
NSArray*)
shortStandaloneQuarterSymbols;
Availability: MacOS-X 10.5.0
Description forthcoming.
- (
NSArray*)
shortStandaloneWeekdaySymbols;
Availability: MacOS-X 10.5.0
Description forthcoming.
- (
NSArray*)
shortWeekdaySymbols;
Availability: MacOS-X 10.4.0
Description forthcoming.
- (
NSArray*)
standaloneMonthSymbols;
Availability: MacOS-X 10.5.0
Description forthcoming.
- (
NSArray*)
standaloneQuarterSymbols;
Availability: MacOS-X 10.5.0
Description forthcoming.
- (
NSArray*)
standaloneWeekdaySymbols;
Availability: MacOS-X 10.5.0
Description forthcoming.
- (
NSString*)
stringFromDate: (
NSDate*)date;
Availability: MacOS-X 10.4.0
Description forthcoming.
- (
NSTimeZone*)
timeZone;
Availability: MacOS-X 10.4.0
Description forthcoming.
- (
NSDate*)
twoDigitStartDate;
Availability: MacOS-X 10.4.0
Description forthcoming.
- (
NSArray*)
veryShortMonthSymbols;
Availability: MacOS-X 10.5.0
Description forthcoming.
- (
NSArray*)
veryShortStandaloneMonthSymbols;
Availability: MacOS-X 10.5.0
Description forthcoming.
- (
NSArray*)
veryShortStandaloneWeekdaySymbols;
Availability: MacOS-X 10.5.0
Description forthcoming.
- (
NSArray*)
veryShortWeekdaySymbols;
Availability: MacOS-X 10.5.0
Description forthcoming.
- (
NSArray*)
weekdaySymbols;
Availability: MacOS-X 10.4.0
Description forthcoming.
Instance Variables for NSDateFormatter Class
@protected BOOL _allowsNaturalLanguage;
Availability: MacOS-X 10.0.0
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
@protected NSString* _dateFormat;
Availability: MacOS-X 10.0.0
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
Up