FSCalendar icon indicating copy to clipboard operation
FSCalendar copied to clipboard

after initialize FSCalendar with week model, the currentPage isn't the firstDay of week

Open talka123456 opened this issue 4 years ago • 4 comments

当首次初始化FSCalendar后,设置周模式,并且firstWeekday = 2(周一为第一天), 此时获取到的currentPage 并不是当前周的第一天,而是中间时间, 问题出现在FSCalendar所有版本中,测试demo使用Example-Objc中的FSCalendarScope Example页面,初始化后首次获取currentPage 数据出错,调用calendarCurrentPageDidChange一次后数据恢复正常,

跟踪源码发现是 class : FSCalendarTransitionCoordinator method: createTransitionAttributesTargetingScope line : 277 行 createTransitionAttributesTargetingScope 函数中 在设置targetpage时,如果是周模式用的是fs_middleDayOfWeek函数获取时间,月模式是fs_firstDayOfMonth获取, 并在后面逻辑赋值给currentPage, 不知道您是出于什么考虑,此处导致初始化后, 首次currentpage数据是周中时间,而非首天时间 希望可以获取您的技术支持

talka123456 avatar Oct 25 '19 01:10 talka123456

这是因为有可能本周第一天是上个月(如9月)最后一天,其他6天都是本月(如10月)的,这个时候是10月。中间一天一定属于本周天数最多的那个月。

WenchaoD avatar Oct 25 '19 03:10 WenchaoD

所以在首次初始化之后,是无法通过currentPage获取当前周 第一天日期的,除了自己计算以外,有没有其他属性能直接获取初始化后的这个时间信息

talka123456 avatar Oct 26 '19 01:10 talka123456

Hi, Anyone find solution to this. I'm getting the same issue. The currentPage is returning wrong date as middle of the week when switched from month mode to week mode.

RAITERN avatar Apr 18 '22 10:04 RAITERN