Advertisement
Larme

Untitled

Mar 1st, 2024 (edited)
706
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 1.00 KB | None | 0 0
  1. func formatsDates() {
  2.     let dateFormatter = DateFormatter()
  3.     dateFormatter.dateFormat = "yyyy-MM-dd"
  4.  
  5.     let ids: [Calendar.Identifier] = [.buddhist, .chinese, .coptic, .ethiopicAmeteAlem, .ethiopicAmeteMihret, .gregorian, .hebrew, .indian, .islamic, .islamicCivil, .islamicTabular, .islamicUmmAlQura, .iso8601, .japanese, .persian, .republicOfChina]
  6.    
  7.     ids.forEach {
  8.         dateFormatter.calendar = Calendar(identifier: $0)
  9.         print("For \($0) got: \(dateFormatter.string(from: Date()))")
  10.     }
  11. }
  12.  
  13.  
  14. Output:
  15.  
  16. For buddhist got: 2567-03-01
  17. For chinese got: 0041-01-21
  18. For coptic got: 1740-06-22
  19. For ethioaa got: 2024-03-01
  20. For ethiopic got: 2016-06-22
  21. For gregorian got: 2024-03-01
  22. For hebrew got: 5784-06-21
  23. For indian got: 1945-12-11
  24. For islamic got: 1445-08-21
  25. For islamic-civil got: 1445-08-20
  26. For islamic-tbla got: 1445-08-21
  27. For islamic-umalqura got: 1445-08-20
  28. For iso8601 got: 2024-03-01
  29. For japanese got: 0006-03-01
  30. For persian got: 1402-12-11
  31. For roc got: 0113-03-01
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement