api-generator-templates/Swift/ApiDateFormattingService.sw...

32 lines
696 B
Twig

{%- import 'macroses/common.utils.twig' as utils -%}
{%- set hasDateFormats = dateFormats is not empty -%}
{%- if hasDateFormats %}
import LeadKit
import SwiftDate
enum ApiDateFormat: String, LeadKit.DateFormat {
{% for format in dateFormats -%}
case {{ format.name }} = "{{ format.format }}"
{% endfor %}
var swiftDateFormat: SwiftDate.DateFormat {
return SwiftDate.DateFormat.custom(rawValue)
}
}
final class ApiDateFormattingService: DateFormattingService, Singleton {
typealias DateFormatType = ApiDateFormat
var currentRegion: Region = .Local()
static let shared = ApiDateFormattingService()
private init() {}
}
{{ "\n" }}
{%- endif -%}