Last active
August 19, 2023 09:24
-
-
Save yycking/3f632697ff3853f0efd3d1dcac6dadbb to your computer and use it in GitHub Desktop.
list DateFormatter result
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Cocoa | |
extension DateFormatter.Style { | |
static public var allCases: [DateFormatter.Style] = [ | |
.none, | |
.short, | |
.medium, | |
.long, | |
.full, | |
] | |
} | |
extension DateFormatter.Style: CustomStringConvertible { | |
public var description: String { | |
switch self { | |
case .none: | |
return "none " | |
case .short: | |
return "short " | |
case .medium: | |
return "medium" | |
case .long: | |
return "long " | |
case .full: | |
return "full " | |
} | |
} | |
} | |
let formatter = DateFormatter() | |
for dateStyle in DateFormatter.Style.allCases { | |
formatter.dateStyle = dateStyle | |
for timeStyle in DateFormatter.Style.allCases { | |
formatter.timeStyle = timeStyle | |
print("(\(dateStyle)|\(timeStyle)) \(formatter.string(from: Date()))") | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(none |none ) | |
(none |short ) 1:31 PM | |
(none |medium) 1:31:30 PM | |
(none |long ) 1:31:30 PM GMT+8 | |
(none |full ) 1:31:30 PM Taipei Standard Time | |
(short |none ) 2020/11/23 | |
(short |short ) 2020/11/23, 1:31 PM | |
(short |medium) 2020/11/23, 1:31:30 PM | |
(short |long ) 2020/11/23, 1:31:30 PM GMT+8 | |
(short |full ) 2020/11/23, 1:31:30 PM Taipei Standard Time | |
(medium|none ) Nov 23, 2020 | |
(medium|short ) Nov 23, 2020 at 1:31 PM | |
(medium|medium) Nov 23, 2020 at 1:31:30 PM | |
(medium|long ) Nov 23, 2020 at 1:31:30 PM GMT+8 | |
(medium|full ) Nov 23, 2020 at 1:31:30 PM Taipei Standard Time | |
(long |none ) November 23, 2020 | |
(long |short ) November 23, 2020 at 1:31 PM | |
(long |medium) November 23, 2020 at 1:31:30 PM | |
(long |long ) November 23, 2020 at 1:31:30 PM GMT+8 | |
(long |full ) November 23, 2020 at 1:31:30 PM Taipei Standard Time | |
(full |none ) Monday, November 23, 2020 | |
(full |short ) Monday, November 23, 2020 at 1:31 PM | |
(full |medium) Monday, November 23, 2020 at 1:31:30 PM | |
(full |long ) Monday, November 23, 2020 at 1:31:30 PM GMT+8 | |
(full |full ) Monday, November 23, 2020 at 1:31:30 PM Taipei Standard Time |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(none |none ) | |
(none |short ) 下午1:34 | |
(none |medium) 下午1:34:19 | |
(none |long ) GMT+8 下午1:34:19 | |
(none |full ) 台北標準時間 下午1:34:19 | |
(short |none ) 2020/11/23 | |
(short |short ) 2020/11/23 下午1:34 | |
(short |medium) 2020/11/23 下午1:34:19 | |
(short |long ) 2020/11/23 GMT+8 下午1:34:19 | |
(short |full ) 2020/11/23 台北標準時間 下午1:34:19 | |
(medium|none ) 2020年11月23日 | |
(medium|short ) 2020年11月23日 下午1:34 | |
(medium|medium) 2020年11月23日 下午1:34:19 | |
(medium|long ) 2020年11月23日 GMT+8 下午1:34:19 | |
(medium|full ) 2020年11月23日 台北標準時間 下午1:34:19 | |
(long |none ) 2020年11月23日 | |
(long |short ) 2020年11月23日 下午1:34 | |
(long |medium) 2020年11月23日 下午1:34:19 | |
(long |long ) 2020年11月23日 GMT+8 下午1:34:19 | |
(long |full ) 2020年11月23日 台北標準時間 下午1:34:19 | |
(full |none ) 2020年11月23日 星期一 | |
(full |short ) 2020年11月23日 星期一 下午1:34 | |
(full |medium) 2020年11月23日 星期一 下午1:34:19 | |
(full |long ) 2020年11月23日 星期一 GMT+8 下午1:34:19 | |
(full |full ) 2020年11月23日 星期一 台北標準時間 下午1:34:19 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment