Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Foundation
- class Kalendarz{
- var components = DateComponents()
- init(){
- components.day = 1
- components.month = 1
- components.year = 2019
- components.hour = 0
- components.minute = 0
- }
- subscript(day: Int) -> String{
- get {
- components.day = day
- let calendar = Calendar.current
- let dateFormatter = DateFormatter()
- dateFormatter.dateFormat = "dd-MMMM-yyyy"
- let date = dateFormatter.string(from: calendar.date(from: self.components)!)
- return date
- }
- }
- subscript(day: Int, year: Int) -> String{
- get {
- components.day = day
- components.year = year
- let calendar = Calendar.current
- let dateFormatter = DateFormatter()
- dateFormatter.dateFormat = "dd-MMMM-yyyy"
- let date = dateFormatter.string(from: calendar.date(from: self.components)!)
- return date
- }
- }
- }
- var c = Kalendarz()
- var wynik: String
- wynik = c[40]
- var a = c[2,1990]
- print(wynik)
- print(a)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement