Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do you get the visible date range in calendar #503

Closed
Nidhee opened this issue Nov 29, 2016 · 5 comments
Closed

How do you get the visible date range in calendar #503

Nidhee opened this issue Nov 29, 2016 · 5 comments

Comments

@Nidhee
Copy link

Nidhee commented Nov 29, 2016

Hello,

Is there any way to get visible minimum and maximum date (start and end date).

The following informations are requested in a bug report

  • A brief bug description.
  • Stack trace.
  • Integration method.(manually/cocoapods/carthage)
  • Full steps to reproduce.
  • Device modal and iOS version. e.g. iPhone 6s iOS9.1
  • Xcode version. e.g. Xcode 8.1
  • FSCalendar version. e.g. FSCalenda 2.5.1
  • Does this happen in the demo project? Which one? Or a link to another demo project.

如果在使用过程中遇到问题,请提供以下信息以便于尽快将问题修复

  • 简单描述一下问题。
  • 控制台输出的堆栈跟踪(如果有的话)。
  • 安装方式. 如手动安装、cocoapods安装、或者通过carthage安装
  • 能够重现此问题的完整步骤。
  • 设备型号及版本。 例如: iPhone6s iOS9.1
  • 使用的Xcode版本。 例如: Xcode8.1
  • FSCalendar版本. 例如: FSCalendar 2.5.1
  • 是否能在demo中重现,以及在哪个demo中重现?或者附加一个重现问题的demo链接。
@WenchaoD
Copy link
Owner

Hi @Nidhee . There is no public interface for this. But the minimum in the visible area was stored in the monthHead NSCache instance in FSCalendarCalculator, and the maximum can simply fetched by plusing a 42 of the head. Hope this helps.

@riki-dexter
Copy link

Hi @WenchaoD, how can i use FSCalendarCalculator?

@allenhuang
Copy link

Hi,
By the hint of monthHead, I finally use the following codes to get visible date range in calendar.

let startDate: Date
let endDate: Date?
if self.calendar.scope == .week {
    startDate = self.calendar.currentPage
    endDate = self.calendar.gregorian.date(byAdding: .day, value: 6, to: startDate)
} else { // .month
    let indexPath = self.calendar.calculator.indexPath(for: self.calendar.currentPage, scope: .month)
    startDate = self.calendar.calculator.monthHead(forSection: (indexPath?.section)!)!
    endDate = self.calendar.gregorian.date(byAdding: .day, value: 41, to: startDate)
}

@mallikarjuna0308
Copy link

Thanks a lot @allenhuang but it is working only when I install FSCalendar through pods. When I added FSCalendar manually in my project it throws an error stating Calculator is not a member of calendar. Could you please help me in this regard?

@rubensbubens
Copy link

rubensbubens commented Jan 11, 2023

̶H̶a̶v̶i̶n̶g̶ ̶t̶h̶e̶ ̶s̶a̶m̶e̶ ̶i̶s̶s̶u̶e̶ ̶b̶u̶t̶ ̶i̶n̶ ̶S̶w̶i̶f̶t̶.̶ ̶C̶a̶l̶c̶u̶l̶a̶t̶o̶r̶ ̶p̶r̶o̶p̶e̶r̶t̶y̶ ̶i̶s̶ ̶i̶n̶a̶c̶c̶e̶s̶s̶i̶b̶l̶e̶ ̶a̶n̶d̶ ̶g̶r̶a̶b̶b̶i̶n̶g̶ ̶d̶a̶t̶e̶s̶ ̶f̶r̶o̶m̶ ̶v̶i̶s̶i̶b̶l̶e̶ ̶c̶e̶l̶l̶s̶ ̶i̶s̶ ̶n̶o̶t̶ ̶a̶ ̶g̶o̶o̶d̶ ̶a̶p̶p̶r̶o̶a̶c̶h̶ ̶f̶o̶r̶ ̶m̶e̶,̶ ̶c̶u̶z̶ ̶c̶e̶l̶l̶s̶ ̶a̶r̶e̶ ̶t̶a̶k̶i̶n̶g̶ ̶s̶h̶o̶r̶t̶ ̶t̶i̶m̶e̶ ̶t̶o̶ ̶a̶p̶p̶e̶a̶r̶.̶ ̶B̶u̶t̶ ̶I̶ ̶n̶e̶e̶d̶ ̶t̶o̶ ̶h̶a̶v̶e̶ ̶a̶ ̶s̶y̶n̶c̶h̶r̶o̶n̶o̶u̶s̶ ̶w̶a̶y̶ ̶t̶o̶ ̶g̶e̶t̶ ̶p̶a̶g̶e̶'̶s̶ ̶s̶t̶a̶r̶t̶/̶e̶n̶d̶ ̶d̶a̶t̶e̶s̶ ̶a̶s̶ ̶s̶o̶o̶n̶ ̶a̶s̶ ̶p̶o̶s̶s̶i̶b̶l̶e̶ ̶t̶o̶ ̶f̶e̶t̶c̶h̶ ̶a̶n̶d̶ ̶c̶a̶l̶c̶u̶l̶a̶t̶e̶ ̶e̶v̶e̶n̶t̶ ̶m̶a̶r̶k̶e̶r̶s̶.̶

Don't know is there was any update, but now the answer from @allenhuang works :)

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

No branches or pull requests

6 participants