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 to get Current year, current month & number of days in a month ? #508

Closed
riazurcse opened this issue Dec 6, 2016 · 2 comments
Closed

Comments

@riazurcse
Copy link

How to get Current year, current month & number of days in a month ?

Previously i used
let calender = FSCalendar()
CURRENT_YEAR = calendar.currentPage.fs_year
CURRENT_MONTH = calendar.currentPage.fs_month
TOTAL_DAYS = calendar.currentPage.fs_numberOfDaysInMonth

After moving to swift 3 & updated the library it's not working. Please help. Thanks.

@kallahir
Copy link
Contributor

If it's not working you can try using Calendar from Foundation API. You can get the values that you want with the following code:

let values = Calendar.current.dateComponents([Calendar.Component.month, Calendar.Component.year], from: self.calendar.currentPage)
CURRENT_YEAR = values.year
CURRENT_MONTH = values.month

let range = Calendar.current.range(of: Calendar.Component.day, in: Calendar.Component.month, for: self.calendar.currentPage)
TOTAL_DAYS = range.count

@malqadi88
Copy link

Dears,
there is problem showing in header view FS Calendar Collection View the problem years is reserved

if current date 11/2017 will show 11/2018 first item when app is support Right to left
using forceRightToLeft Semantic view

can you help me ?

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

4 participants