1 /* Copyright (c) 2006-2007 Christopher J. W. Lloyd
3 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
9 #import <Foundation/NSFormatter.h>
10 #import <Foundation/NSDate.h>
11 #import <CoreFoundation/CFDateFormatter.h>
14 NSDateFormatterBehaviorDefault
= 0,
15 NSDateFormatterBehavior10_0
= 1000,
16 NSDateFormatterBehavior10_4
= 1040,
17 } NSDateFormatterBehavior
;
20 NSDateFormatterNoStyle
= kCFDateFormatterNoStyle
,
21 NSDateFormatterShortStyle
= kCFDateFormatterShortStyle
,
22 NSDateFormatterMediumStyle
= kCFDateFormatterMediumStyle
,
23 NSDateFormatterLongStyle
= kCFDateFormatterLongStyle
,
24 NSDateFormatterFullStyle
= kCFDateFormatterFullStyle
25 } NSDateFormatterStyle
;
27 @interface NSDateFormatter
: NSFormatter
{
28 NSDateFormatterBehavior _behavior
;
29 NSDateFormatterStyle _dateStyle
;
30 NSDateFormatterStyle _timeStyle
;
31 NSString
*_dateFormat10_0
;
32 NSString
*_dateFormat
;
33 BOOL _allowsNaturalLanguage
;
34 NSDictionary
*_locale
;
38 - initWithDateFormat
:(NSString
*)format allowNaturalLanguage
:(BOOL
)flag
; // shouldn't this be "allows" ?
40 // added because NSDateFormatter is the backend for initWithString:calendarFormat:locale
41 // shouldn't this really exist anyway?
42 - initWithDateFormat
:(NSString
*)format allowNaturalLanguage
:(BOOL
)flag locale
:(NSDictionary
*)locale
;
44 - (NSString
*)dateFormat
;
45 - (BOOL
)allowsNaturalLanguage
;
46 - (NSDateFormatterBehavior
)formatterBehavior
;
48 - (NSDictionary
*)locale
;
50 - (void)setDateFormat
:(NSString
*)format
;
52 - (NSString
*)stringFromDate
:(NSDate
*)date
;
53 - (NSDate
*)dateFromString
:(NSString
*)string
;
54 - (NSArray
*)shortStandaloneWeekdaySymbols
;
55 - (NSArray
*)standaloneWeekdaySymbols
;
57 - (void)setLenient
:(BOOL
)value
;
58 - (void)setFormatterBehavior
:(NSDateFormatterBehavior
)value
;
59 - (void)setTimeZone
:(NSTimeZone
*)tz
;
60 - (NSTimeZone
*)timeZone
;
66 NSTimeInterval
NSMoveIntervalFromTimeZoneToGMT(NSTimeInterval interval
, NSTimeZone
*timeZone
);
67 NSTimeInterval
NSMoveIntervalFromGMTToTimeZone(NSTimeInterval interval
, NSTimeZone
*timeZone
);
69 NSInteger
NSNumberOfDaysInMonthOfYear(NSInteger month
, NSInteger year
);
70 // interval is not time zone adjusteed
71 NSTimeInterval
NSTimeIntervalWithComponents(NSInteger year
, NSInteger month
, NSInteger day
, NSInteger hour
, NSInteger minute
, NSInteger second
, NSInteger milliseconds
);
73 // interval has already been time zone adjusted
74 NSInteger
NSDayOfCommonEraFromTimeInterval(NSTimeInterval interval
);
76 NSInteger
NSYearFromTimeInterval(NSTimeInterval interval
);
77 NSInteger
NSDayOfYearFromTimeInterval(NSTimeInterval interval
); // 1-366
79 NSInteger
NSMonthFromTimeInterval(NSTimeInterval interval
); // 1-12
80 NSInteger
NSDayOfMonthFromTimeInterval(NSTimeInterval interval
); // 0-31
82 NSInteger
NSWeekdayFromTimeInterval(NSTimeInterval interval
); // 1-7
84 NSInteger
NS24HourFromTimeInterval(NSTimeInterval interval
); // 0-23
85 NSInteger
NS12HourFromTimeInterval(NSTimeInterval interval
); // 1-12
86 NSInteger
NSAMPMFromTimeInterval(NSTimeInterval interval
); // 0-1
88 NSInteger
NSMinuteFromTimeInterval(NSTimeInterval interval
); // 0-59
90 NSInteger
NSSecondFromTimeInterval(NSTimeInterval interval
); // 0-59
92 NSInteger
NSMillisecondsFromTimeInterval(NSTimeInterval interval
); // 0-999
94 // interval will be time-zone adjusted
95 NSString
*NSStringWithDateFormatLocale(NSTimeInterval interval
, NSString
*format
, NSDictionary
*locale
, NSTimeZone
*timeZone
);
97 NSDate
*NSDateWithStringDateFormatLocale(NSString
*string
, NSString
*format
, NSDictionary
*locale
, NSTimeZone
*timeZone
);