date_utils icon indicating copy to clipboard operation
date_utils copied to clipboard

First Day of Week

Open flowhorn opened this issue 7 years ago • 4 comments

Hello, I really like your work, especially the calendar widget for flutter, as i use it in my app. And it is wonderful. But I would like to have the calendar not starting sunday and ending saturday, but from monday to sunday. This would be fantastic!

flowhorn avatar Aug 14 '18 17:08 flowhorn

+1 It would be awesome if you could give us an option with which day of the week we would like to start. Thanks for the great work tho!

Sadoge avatar Sep 07 '18 08:09 Sadoge

This is already a fantastic proyect, but having this option woudl be amazing.

JoeyMontero avatar Nov 16 '18 12:11 JoeyMontero

Yes! For weekly calendar it should start from Monday, then only it will be useful. lot of other calendar providers doing that otherwise integrations will become tough.

rravithejareddy avatar Feb 05 '19 17:02 rravithejareddy

Set firstWeekday = 1 in DateModel

and replace following code

func indexAtBeginning(in month: MonthType) -> Int?{ if let index = calendar.ordinality(of: .day, in: .weekOfMonth, for: atBeginning(of: month)) { let finalIndex = index - 2 if finalIndex < 0{ return 7 + finalIndex // + because final index is in negative } return finalIndex } return nil }

ghazi256 avatar Jan 16 '20 07:01 ghazi256