diff --git a/Swift/ApiDateFormattingService.swift.twig b/Swift/ApiDateFormattingService.swift.twig index 2521dca..1e77084 100644 --- a/Swift/ApiDateFormattingService.swift.twig +++ b/Swift/ApiDateFormattingService.swift.twig @@ -11,8 +11,8 @@ enum ApiDateFormat: String, LeadKit.DateFormat { {% for format in dateFormats -%} case {{ format.name }} = "{{ format.format }}" {% endfor %} - var swiftDateFormat: SwiftDate.DateFormat { - return SwiftDate.DateFormat.custom(rawValue) + var swiftDateFormat: DateToStringStyles { + return .custom(rawValue) } } @@ -21,7 +21,7 @@ final class ApiDateFormattingService: DateFormattingService, Singleton { typealias DateFormatType = ApiDateFormat - var currentRegion: Region = .Local() + var currentRegion: Region = .local static let shared = ApiDateFormattingService() diff --git a/Swift/macroses/common.utils.twig b/Swift/macroses/common.utils.twig index 65233d1..ee630a8 100644 --- a/Swift/macroses/common.utils.twig +++ b/Swift/macroses/common.utils.twig @@ -33,7 +33,7 @@ {%- if field.type.type.baseTypeName == "DateTime" -%} {{ self.formatNullableOrOptional(field.name, field.nullable, field.optional) -}} - .string(format: ApiDateFormat.{{ dateFormatToName(field.type.dateFormat) }}.swiftDateFormat) + .toString(ApiDateFormat.{{ dateFormatToName(field.type.dateFormat) }}.swiftDateFormat) {%- elseif field.type.type.baseTypeName == "Decimal" -%} {{ self.formatNullableOrOptional(field.name, field.nullable, field.optional) -}} .decimalValue @@ -103,12 +103,12 @@ {% macro initExpr(field) %} {%- if field.type.type.baseTypeName == "DateTime" -%} - if let date = DateInRegion(string: {{ field.name }}, format: ApiDateFormat.{{ dateFormatToName(field.type.dateFormat) }}.swiftDateFormat, fromRegion: ApiDateFormattingService.shared.currentRegion) { + if let date = ApiDateFormattingService.date(from: {{ field.name }}, format: "{{ field.type.dateFormat }}") { self.{{ field.name }} = date } else { throw LeadKitError.failedToDecode(reason: "init?(string:format:fromRegion:) returned nil") } - {%- elseif field.type.type.baseTypeName == "Decimal" -%} + {%- elseif field.type.type.baseTypeName == "Decimal" -%} self.{{ field.name }} = NSDecimalNumber(decimal: {{ field.name }}) {%- endif -%} {% endmacro %} @@ -133,7 +133,7 @@ {%- elseif baseTypeName == "String" -%} "" {%- elseif baseTypeName == "DateTime" -%} - Date().inRegion() + Date().inDefaultRegion() {%- elseif baseTypeName == "Double" -%} 0.0 {%- elseif baseTypeName == "Long" or baseTypeName == "Int" -%}