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
-
validateLocale
property -
checkSameLocale
property -
ansiFormatter
property -
targetFormatter
property -
– 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 *ansiFormatter
Declared In
SqlitePersistentDateFormatter.h
checkSameLocale
A boolean flag to enable/disable the locale identifier change check in the [SqlitePersistentDateFormatter setFormat:locale:] method.
@property (nonatomic) BOOL checkSameLocale
Discussion
YES - locale identifier validation is performed only on locale change. NO - locale identifier validation is performed at each locale object assignment.
Declared In
SqlitePersistentDateFormatter.h
targetFormatter
An instance of the target formatter configured by the [SqlitePersistentDateFormatter setFormat:locale:] method.
@property (nonatomic, readonly) NSDateFormatter *targetFormatter
Declared In
SqlitePersistentDateFormatter.h
validateLocale
A boolean flag to enable/disable locale identifier validation in the [SqlitePersistentDateFormatter setFormat:locale:] method.
@property (nonatomic) BOOL validateLocale
Discussion
YES - safe but slow. NO - fast but requires correct input.
Declared In
SqlitePersistentDateFormatter.h
Class Methods
freeInstance
Deallocates a shared instance of the SqlitePersistentDateFormatter singleton. The method is thread-safe.
+ (void)freeInstance
Declared In
SqlitePersistentDateFormatter.h
halfYearForDate: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.h
Instance 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.h
getFullYearAndHalfYear:
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.h
getHalfYearAndFullYearFromDate:
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.h
getQuarterAndFullYear:
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.h
getQuarterAndFullYearFromDate:
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.h
getYearAndHalfYear:
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.h
getYearAndHalfYearPOD:
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.h
getYearAndQuarter:
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.h
getYearAndQuarterPOD:
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.h
setFormat: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