Merge pull request #158 from TouchInstinct/feature/swift_date_migration_part_2
Feature/swift date migration part 2
This commit is contained in:
commit
acd5b39c33
|
|
@ -1,5 +1,11 @@
|
|||
# Changelog
|
||||
|
||||
### 0.8.8
|
||||
- **Update**: Update `DateFormat` protocol. Add `dateToStringFormat` and `stringToDateFormat` according to SwiftDate 5.0.
|
||||
- **Update**: Replace `String` with `DateFormat` in `DataFormattingService` date parsing methods.
|
||||
- **Update**: Replace `DateInRegion` with `DateRepresentable` in `DataFormattingService` string formatting methods.
|
||||
- **Add**: `parsedIn` optional parameter to date parsing method in `DataFormattingService`.
|
||||
|
||||
### 0.8.7
|
||||
- **Add**: Base configurable controllers hierarchy with generic custom view argument (`BaseConfigurableController`, `BaseCustomViewController`, `BaseScrollContentController`, `BaseTableContentController` and `BaseCollectionContentController`).
|
||||
- **Add**: `ScrollViewHolder`, `TableViewHolder` and `CollectionViewHolder` protocols.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
Pod::Spec.new do |s|
|
||||
s.name = "LeadKit"
|
||||
s.version = "0.8.7"
|
||||
s.version = "0.8.8"
|
||||
s.summary = "iOS framework with a bunch of tools for rapid development"
|
||||
s.homepage = "https://github.com/TouchInstinct/LeadKit"
|
||||
s.license = "Apache License, Version 2.0"
|
||||
|
|
|
|||
|
|
@ -25,26 +25,31 @@ import SwiftDate
|
|||
public extension DateFormattingService {
|
||||
|
||||
func date(from string: String,
|
||||
format: String,
|
||||
format: DateFormatType,
|
||||
defaultDate: DateInRegion = Date().inDefaultRegion()) -> DateInRegion {
|
||||
|
||||
return date(from: string, format: format) ?? defaultDate
|
||||
return date(from: string, format: format, parsedIn: nil) ?? defaultDate
|
||||
}
|
||||
|
||||
func date(from string: String, format: String) -> DateInRegion? {
|
||||
return DateInRegion(string, format: format, region: currentRegion)
|
||||
func date(from string: String,
|
||||
format: DateFormatType,
|
||||
parsedIn: Region?) -> DateInRegion? {
|
||||
|
||||
let region = parsedIn ?? currentRegion
|
||||
|
||||
return format.stringToDateFormat.toDate(string, region: region)
|
||||
}
|
||||
|
||||
func string(from date: DateInRegion, format: DateFormatType) -> String {
|
||||
return date.toString(format.swiftDateFormat)
|
||||
func string(from date: DateRepresentable, format: DateFormatType) -> String {
|
||||
return format.dateToStringFormat.toString(date)
|
||||
}
|
||||
|
||||
func string(from date: DateInRegion, format: DateFormatType, formattedIn: Region? = nil) -> String {
|
||||
func string(from date: DateRepresentable, format: DateFormatType, formattedIn: Region?) -> String {
|
||||
let region = formattedIn ?? currentRegion
|
||||
|
||||
let dateInFormatterRegion = date.convertTo(region: region)
|
||||
|
||||
return dateInFormatterRegion.toString(format.swiftDateFormat)
|
||||
return format.dateToStringFormat.toString(dateInFormatterRegion)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -60,7 +65,7 @@ public extension DateFormattingService where Self: Singleton {
|
|||
/// - defaultDate: Default date if formatting will fail.
|
||||
/// - Returns: Date parsed from given string or default date if parsing did fail.
|
||||
static func date(from string: String,
|
||||
format: String,
|
||||
format: DateFormatType,
|
||||
defaultDate: DateInRegion = Date().inDefaultRegion()) -> DateInRegion {
|
||||
|
||||
return shared.date(from: string, format: format, defaultDate: defaultDate)
|
||||
|
|
@ -71,9 +76,10 @@ public extension DateFormattingService where Self: Singleton {
|
|||
/// - Parameters:
|
||||
/// - string: String to use for date parsing.
|
||||
/// - format: Format that should be used for date parsing.
|
||||
/// - parsedIn: A region that should be used for date parsing. In case of nil defaultRegion will be used.
|
||||
/// - Returns: Date parsed from given string or default date if parsing did fail.
|
||||
static func date(from string: String, format: String) -> DateInRegion? {
|
||||
return shared.date(from: string, format: format)
|
||||
static func date(from string: String, format: DateFormatType, parsedIn: Region?) -> DateInRegion? {
|
||||
return shared.date(from: string, format: format, parsedIn: parsedIn)
|
||||
}
|
||||
|
||||
/// Method format date in given format.
|
||||
|
|
@ -82,7 +88,7 @@ public extension DateFormattingService where Self: Singleton {
|
|||
/// - date: Date to format.
|
||||
/// - format: Format that should be used for date formatting.
|
||||
/// - Returns: String that contains formatted date or nil if formatting did fail.
|
||||
static func string(from date: DateInRegion, format: DateFormatType) -> String {
|
||||
static func string(from date: DateRepresentable, format: DateFormatType) -> String {
|
||||
return shared.string(from: date, format: format)
|
||||
}
|
||||
|
||||
|
|
@ -93,7 +99,7 @@ public extension DateFormattingService where Self: Singleton {
|
|||
/// - format: Format that should be used for date formatting.
|
||||
/// - formattedIn: A region that should be used for date formatting. In case of nil defaultRegion will be used.
|
||||
/// - Returns: String that contains formatted date or nil if formatting did fail.
|
||||
static func string(from date: DateInRegion, format: DateFormatType, formattedIn: Region?) -> String {
|
||||
static func string(from date: DateRepresentable, format: DateFormatType, formattedIn: Region?) -> String {
|
||||
return shared.string(from: date, format: format, formattedIn: formattedIn)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,10 @@ import SwiftDate
|
|||
/// Protocol for describing date format.
|
||||
public protocol DateFormat {
|
||||
|
||||
/// SwiftDate.DateFormat for current format.
|
||||
var swiftDateFormat: DateToStringStyles { get }
|
||||
/// Date to string style for current format.
|
||||
var dateToStringFormat: DateToStringStyles { get }
|
||||
|
||||
/// String to date style for current format.
|
||||
var stringToDateFormat: StringToDateStyles { get }
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,15 +38,16 @@ public protocol DateFormattingService {
|
|||
/// - format: Format that should be used for date parsing.
|
||||
/// - defaultDate: Default date if formatting will fail.
|
||||
/// - Returns: Date parsed from given string or default date if parsing did fail.
|
||||
func date(from string: String, format: String, defaultDate: DateInRegion) -> DateInRegion
|
||||
func date(from string: String, format: DateFormatType, defaultDate: DateInRegion) -> DateInRegion
|
||||
|
||||
/// Method parses date from string in given format with current region.
|
||||
/// Method parses date from string in given format with passed region.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - string: String to use for date parsing.
|
||||
/// - format: Format that should be used for date parsing.
|
||||
/// - parsedIn: A region that should be used for date parsing. In case of nil defaultRegion will be used.
|
||||
/// - Returns: Date parsed from given string or default date if parsing did fail.
|
||||
func date(from string: String, format: String) -> DateInRegion?
|
||||
func date(from string: String, format: DateFormatType, parsedIn: Region?) -> DateInRegion?
|
||||
|
||||
/// Method format date in given format.
|
||||
///
|
||||
|
|
@ -54,7 +55,7 @@ public protocol DateFormattingService {
|
|||
/// - date: Date to format.
|
||||
/// - format: Format that should be used for date formatting.
|
||||
/// - Returns: String that contains formatted date or nil if formatting did fail.
|
||||
func string(from date: DateInRegion, format: DateFormatType) -> String
|
||||
func string(from date: DateRepresentable, format: DateFormatType) -> String
|
||||
|
||||
/// Method format date in given format for specific region.
|
||||
///
|
||||
|
|
@ -63,6 +64,6 @@ public protocol DateFormattingService {
|
|||
/// - format: Format that should be used for date formatting.
|
||||
/// - formattedIn: A region that should be used for date formatting. In case of nil defaultRegion will be used.
|
||||
/// - Returns: String that contains formatted date or nil if formatting did fail.
|
||||
func string(from date: DateInRegion, format: DateFormatType, formattedIn: Region?) -> String
|
||||
func string(from date: DateRepresentable, format: DateFormatType, formattedIn: Region?) -> String
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue