weilsonwonder / WWCalendarTimeSelector

A android inspired iOS date/time picker
MIT License
317 stars 126 forks source link

How to make a week begin on Monday instead of Sunday? #50

Open Ewg777 opened 6 years ago

Ewg777 commented 6 years ago

@weilsonwonder is it possible?

joaquinperezlopez commented 6 years ago

Any solution on this?

Ewg777 commented 6 years ago

@joakin8 try to add this to NSDate+Timepiece.swift:

    static var systemWeekdayEuro: Bool?
    var originalWeekday: Int {
        return components.weekday!
    }

    var weekday: Int {
        if Date.systemWeekdayEuro == nil {
            let testDate = Date(timeIntervalSince1970: 0)
            Date.systemWeekdayEuro = testDate.components.weekday == 4 // 1 янв 1970 был четверг
        }
        if Date.systemWeekdayEuro == true {
            return originalWeekday
        }
        let weekdayNumber = components.weekday!
        let result = (weekdayNumber - 1) % 7
        if result == 0 {
            return 7
        }
        return result
    }
joaquinperezlopez commented 6 years ago

Thanks for your help Egw777, I created a fork from a swift 4 version of WWCalendarTimeSelector including your changes, also I added a open var called optionWeekDayStrings in order to be able to change the upper letters of the calendar. Feel free to try it.

It looks that's working well =)

Regads

Ewg777 commented 6 years ago

No problem jokain8