Advertisement
Larme

Untitled

Jul 12th, 2022
1,649
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.86 KB | None | 0 0
  1. let identifiers: [Calendar.Identifier] = [.buddhist, .chinese, .coptic, .ethiopicAmeteAlem, .ethiopicAmeteMihret, .gregorian, .hebrew, .indian, .islamic, .islamicCivil, .islamicTabular, .islamicUmmAlQura, .iso8601, .japanese, .persian, .republicOfChina]
  2. identifiers.forEach {
  3.     let calendar = Calendar(identifier: $0)
  4.     let year = calendar.component(.year, from: Date())
  5.     print("For: \(calendar.identifier) got: \(year)")
  6. }
  7.  
  8. Output:
  9.  
  10. For: buddhist got: 2565
  11. For: chinese got: 39
  12. For: coptic got: 1738
  13. For: ethiopicAmeteAlem got: 7514
  14. For: ethiopicAmeteMihret got: 2014
  15. For: gregorian got: 2022
  16. For: hebrew got: 5782
  17. For: indian got: 1944
  18. For: islamic got: 1443
  19. For: islamicCivil got: 1443
  20. For: islamicTabular got: 1443
  21. For: islamicUmmAlQura got: 1443
  22. For: iso8601 got: 2022
  23. For: japanese got: 4
  24. For: persian got: 1401
  25. For: republicOfChina got: 111
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement