I would like to know how properly get amount of days in each year quarter. With take in to the account leap year.
For example:
- 1 quarter : 90 (or 91 Leap year)
- 2 quarter : 91 -current quarter
- 3 quarter : 92
- 4 quarter : 92
From the docs it is possible to understand that we should divide year 12 into 4 parts. Then get amount of day of each quarter like 3 * (amount of days in 3 months). But how it is could be done in more sophisticated way and without of the hardcode.
You can use DateFormatter dateFormat
"q"
and convert it to integer.Playground testing:
You should use NSCalendar object in order to calculate number of days for each quarter.
For example: for first quarter: 01 Jan to 01 April