Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func formatsDates() {
- let dateFormatter = DateFormatter()
- dateFormatter.dateFormat = "yyyy-MM-dd"
- let ids: [Calendar.Identifier] = [.buddhist, .chinese, .coptic, .ethiopicAmeteAlem, .ethiopicAmeteMihret, .gregorian, .hebrew, .indian, .islamic, .islamicCivil, .islamicTabular, .islamicUmmAlQura, .iso8601, .japanese, .persian, .republicOfChina]
- ids.forEach {
- dateFormatter.calendar = Calendar(identifier: $0)
- print("For \($0) got: \(dateFormatter.string(from: Date()))")
- }
- }
- Output:
- For buddhist got: 2567-03-01
- For chinese got: 0041-01-21
- For coptic got: 1740-06-22
- For ethioaa got: 2024-03-01
- For ethiopic got: 2016-06-22
- For gregorian got: 2024-03-01
- For hebrew got: 5784-06-21
- For indian got: 1945-12-11
- For islamic got: 1445-08-21
- For islamic-civil got: 1445-08-20
- For islamic-tbla got: 1445-08-21
- For islamic-umalqura got: 1445-08-20
- For iso8601 got: 2024-03-01
- For japanese got: 0006-03-01
- For persian got: 1402-12-11
- For roc got: 0113-03-01
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement