Skip to content
This repository has been archived by the owner on Jun 23, 2019. It is now read-only.

How to show calendar month by Date() ? #36

Open
loverde-co opened this issue Sep 2, 2017 · 2 comments
Open

How to show calendar month by Date() ? #36

loverde-co opened this issue Sep 2, 2017 · 2 comments

Comments

@loverde-co
Copy link

If i want some date in specific month, how to show calendar koyomi on that month ?

@springlo
Copy link

springlo commented Dec 20, 2017

update the DateModel.swift:

public enum MonthType {
    case previous
    case current
    case next
    case custom(year: Int, month: Int)
}

then

func display(in month: MonthType) {
        currentDates = []
        currentDate = date(of: month)
        setup()
    }
    func date(of month: MonthType) -> Date {
        var components = DateComponents()
        
            switch month {
                case .previous: components.month = -1
                case .current:  components.month = 0
                case .next:     components.month = 1
                case let .custom(year: year, month: month):
                    components.year = -year
                    components.month = -month
            }
        
        return calendar.date(byAdding: components, to: currentDate) ?? Date()
    }

@mohseen-headyio
Copy link

mohseen-headyio commented Jun 25, 2018

@springlo What about if it is used as a pod ? What do we need to do make this changes reflect ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants