Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. import Foundation
  2.  
  3. class Kalendarz{
  4. var components = DateComponents()
  5. init(){
  6. components.day = 1
  7. components.month = 1
  8. components.year = 2019
  9. components.hour = 0
  10. components.minute = 0
  11. }
  12. subscript(day: Int) -> String{
  13. get {
  14. components.day = day
  15. let calendar = Calendar.current
  16. let dateFormatter = DateFormatter()
  17. dateFormatter.dateFormat = "dd-MMMM-yyyy"
  18. let date = dateFormatter.string(from: calendar.date(from: self.components)!)
  19. return date
  20. }
  21. }
  22. subscript(day: Int, year: Int) -> String{
  23. get {
  24. components.day = day
  25. components.year = year
  26. let calendar = Calendar.current
  27. let dateFormatter = DateFormatter()
  28. dateFormatter.dateFormat = "dd-MMMM-yyyy"
  29. let date = dateFormatter.string(from: calendar.date(from: self.components)!)
  30. return date
  31. }
  32. }
  33. }
  34.  
  35. var c = Kalendarz()
  36. var wynik: String
  37. wynik = c[40]
  38. var a = c[2,1990]
  39. print(wynik)
  40. print(a)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement