DateFormatterConstructor
No description available
Install / Use
/learn @idapgroup/DateFormatterConstructorREADME
DateFormatterConstructor
This is simple DateFormatter extension which allows you to create a DateFormatter instance with a specific date pattern in one line.
So instead of writing:
let formatter = DateFormatter()
formatter.locale = .current
formatter.timeZone = .current
formatter.dateFormat = "HH:mm:ss"
you write:
let formatter = DateFormatter.custom(format: .fullTime(format: .twentyFour))
You can also optionally select the locale and timezone:
let formatter = DateFormatter.custom(format: DateFormatter.DateFormat, locale: Locale(identifier: "en-US"), timeZone: .gmt)
or leave them as default as
.current
if you do not specify a format, the .fullTimeAndDate format will be used by default:
let formatter = DateFormatter.custom()
| Available format templates | Representation |
| -------------------------- |:--------------:|
| .time(withOnly: .hours) | 23 |
| .time(withOnly: .minutes) | 59 |
| .time(withOnly: .seconds) | 59 |
| .time(withOnly: [.hours, .minutes]) | 23:59 |
| .fullTime(format: .twelve) | 11:59:59 |
| .fullTime(format: .twentyFour) | 23:59:59 |
| .fullTime(format: .withAMPM) | 11:59:59 PM |
| .date(withOnly: .day) | 11 |
| .date(withOnly: .numMonth) | 08 |
| .date(withOnly: .shortMonth) | Aug |
| .date(withOnly: .wideMonth) | August |
| .date(withOnly: .shortYear) | 23 |
| .date(withOnly: .wideYear) | 2023 |
| .date(withOnly: [.day, .shortMonth, .shortYear]) | 11 Aug 23 |
| .fullDate(format: .numDate(separator: ",")) | 11,08,2023 |
| .fullDate(format: .shortWordDate) | 11 Aug 2023 |
| .fullDate(format: .fullWordDate) | 11 August 2023 |
| .dayOfWeek(format: .number) | 5 |
| .dayOfWeek(format: .letter) | F |
| .dayOfWeek(format: .abbreviation) | Fri |
| .dayOfWeek(format: .word) | Friday |
| .fullTimeAndDate | 11 August 2023 23:59:59 |
Requirements
iOS 9+. Swift 3.0.
Installation
DateFormatterConstructor is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "DateFormatterConstructor"
DateFormatterConstructor is available through Carthage. To install it, simply add the following line to your Cartfile:
github "idapgroup/DateFormatterConstructor"
License
TableViewCellRegistrar is available under the New BSD license. See the LICENSE file for more info.
Related Skills
node-connect
347.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
108.0kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
347.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
