SqlitePersistentDateFormatter Class Reference
| Inherits from | NSObject |
| Declared in | SqlitePersistentDateFormatter.h SqlitePersistentDateFormatter.mm |
Overview
A core class for ObjcFormatAnsiDateUsingLocale_v2() function. Caches an instance of NSDateFormatter and updates its settings if params change since the previous call.
Implemented as a singleton to be custom SQLite function friendly. Still, you can instantiate it directly.
Warning: The methods are not thread safe unless explicitly documented.
Tasks
-
+ instance -
+ freeInstance -
validateLocaleproperty -
checkSameLocaleproperty -
ansiFormatterproperty -
targetFormatterproperty -
– setFormat:locale: -
– getFormattedDate: -
– getYearAndQuarter: -
– getYearAndHalfYear: -
– getHalfYearAndFullYearFromDate: -
+ halfYearForDate:usingCalendar: -
– getQuarterAndFullYearFromDate: -
– getQuarterAndFullYear: -
– getFullYearAndHalfYear: -
– getYearAndQuarterPOD: -
– getYearAndHalfYearPOD:
Properties
ansiFormatter
An instance of the ANSI date formatter. See [ESLocaleFactory ansiDateFormatter] for details.
@property (nonatomic, readonly) NSDateFormatter *ansiFormatterDeclared In
SqlitePersistentDateFormatter.hcheckSameLocale
A boolean flag to enable/disable the locale identifier change check in the [SqlitePersistentDateFormatter setFormat:locale:] method.
@property (nonatomic) BOOL checkSameLocaleDiscussion
YES - locale identifier validation is performed only on locale change. NO - locale identifier validation is performed at each locale object assignment.
Declared In
SqlitePersistentDateFormatter.htargetFormatter
An instance of the target formatter configured by the [SqlitePersistentDateFormatter setFormat:locale:] method.
@property (nonatomic, readonly) NSDateFormatter *targetFormatterDeclared In
SqlitePersistentDateFormatter.hvalidateLocale
A boolean flag to enable/disable locale identifier validation in the [SqlitePersistentDateFormatter setFormat:locale:] method.
@property (nonatomic) BOOL validateLocaleDiscussion
YES - safe but slow. NO - fast but requires correct input.
Declared In
SqlitePersistentDateFormatter.hClass Methods
freeInstance
Deallocates a shared instance of the SqlitePersistentDateFormatter singleton. The method is thread-safe.
+ (void)freeInstanceDeclared In
SqlitePersistentDateFormatter.hhalfYearForDate:usingCalendar:
An utility function to get a half year from a given date. This method does not throw any exceptions.
+ (NSInteger)halfYearForDate:(NSDate *)date_ usingCalendar:(NSCalendar *)calendar_Parameters
- date_
A date to retrieve the half year.
- calendar_
A properly configured calendar for splitting the date into components.
Return Value
“1” or “2” for valid input. -1 - for nil date object -2 - for nil calendar object
Declared In
SqlitePersistentDateFormatter.hInstance Methods
getFormattedDate:
Applies the specified date format to a given ANSI date string.
- (NSString *)getFormattedDate:(NSString *)strDate_Parameters
- strDate_
A date in ANSI format.
Return Value
A date in the target format specified in the [SqlitePersistentDateFormatter setFormat:locale:] method.
Declared In
SqlitePersistentDateFormatter.hgetFullYearAndHalfYear:
A sorting friendly representation of the half year information. For example : “2014-2” (For “H2 ‘2014”)
- (NSString *)getFullYearAndHalfYear:(NSString *)strDate_Parameters
- strDate_
A date in ANSI format.
Return Value
A formatted date.
Declared In
SqlitePersistentDateFormatter.hgetHalfYearAndFullYearFromDate:
Applies half year and long year formatting. For example, “H2 ‘2014”
- (NSString *)getHalfYearAndFullYearFromDate:(NSDate *)date_Parameters
- date_
A date in ANSI format.
Return Value
A formatted date.
Discussion
Warning : the format is hard coded
Declared In
SqlitePersistentDateFormatter.hgetQuarterAndFullYear:
Applies quarter and long year formatting. For example, “Q4 ‘2014”
- (NSString *)getQuarterAndFullYear:(NSString *)strDate_Parameters
- strDate_
A date in ANSI format.
Return Value
A formatted date.
Discussion
Warning : the format is hard coded
Declared In
SqlitePersistentDateFormatter.hgetQuarterAndFullYearFromDate:
Applies quarter and long year formatting. For example, “Q4 ‘2014”
- (NSString *)getQuarterAndFullYearFromDate:(NSDate *)date_Parameters
- date_
An NSDate object.
Return Value
A formatted date.
Discussion
Warning : the format is hard coded
Declared In
SqlitePersistentDateFormatter.hgetYearAndHalfYear:
Applies half year and short year formatting. For example, “H2 ‘14”
- (NSString *)getYearAndHalfYear:(NSString *)strDate_Parameters
- strDate_
A date in ANSI format.
Return Value
A formatted date.
Discussion
Warning : the format is hard coded
Declared In
SqlitePersistentDateFormatter.hgetYearAndHalfYearPOD:
Parses year and half year information into a C structure that can be formatted in any format supported by this class.
- (ESYearAndHalfYearPOD)getYearAndHalfYearPOD:(NSDate *)date_Parameters
- date_
An NSDate object to format.
Return Value
A POD structure with parsed info.
Declared In
SqlitePersistentDateFormatter.hgetYearAndQuarter:
Applies quarter and short year formatting. For example, “Q4 ‘14”
- (NSString *)getYearAndQuarter:(NSString *)strDate_Parameters
- strDate_
A date in ANSI format.
Return Value
A formatted date.
Discussion
Warning : the format is hard coded
Declared In
SqlitePersistentDateFormatter.hgetYearAndQuarterPOD:
Parses year and quarter information into a C structure that can be formatted in any format supported by this class.
- (ESYearAndQuarterPOD)getYearAndQuarterPOD:(NSDate *)date_Parameters
- date_
An NSDate object to format.
Return Value
A POD structure with parsed info.
Declared In
SqlitePersistentDateFormatter.hsetFormat:locale:
Configures the [SqlitePersistentDateFormatter targetFormatter] object. Performs locale validation as specified by the flags below :
- (BOOL)setFormat:(NSString *)dateFormat_ locale:(NSString *)locale_Parameters
- dateFormat_
Format string for the [SqlitePersistentDateFormatter targetFormatter] object. It should follow the same rules as [NSDateFormatter dateFormat] property.
- locale_
A locale identifier for the [SqlitePersistentDateFormatter targetFormatter] object.
Return Value
YES for successfull NSDateFormatter initialization. NO in case locale identifier validation failed.
Discussion
Declared In
SqlitePersistentDateFormatter.h