Home > other >  Swift. Calendar. veryShortWeekdaySymbols start with Monday
Swift. Calendar. veryShortWeekdaySymbols start with Monday

Time:12-02

I would like to display very Short Weekday symbols starting from Monday.

When I do this in playground:

var calendar = Calendar.current
print(calendar.veryShortWeekdaySymbols)

Result is: ["S", "M", "T", "W", "T", "F", "S"]

I tried also to change firstWeekday:

var calendar = Calendar.current
calendar.firstWeekday = 2
print(calendar.veryShortWeekdaySymbols)

But the result is the same

CodePudding user response:

Try this solution. hope this work for you.

let firstWeekday = 2 // -> Monday

var symbols = calendar.veryShortWeekdaySymbols
symbols = Array(symbols[firstWeekday-1..<symbols.count])   symbols[0..<firstWeekday-1]

Result -> ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]

  • Related