Comments (1)
Looking further into this, it also affects 2011 and 2012, but not 2009 or 2008. Not sure what makes them different.
I notice there's a comment in the code:
// -[NSDateComponents weekOfYear] doesn't explicitly specify what its valid range is. In the Gregorian case, it appears to be [1,52], which means the last day of December is probably going to be week 1 of next year. The same logic extends to other calendars.
so I added this code to -[tableView:numberOfRowsInSection:]
to test out the range methods on NSCalendar:
if ((section == 480) || (section == 504))
{
NSLog(@"section %d", section);
NSLog(@"firstWeek %d", firstWeek);
NSLog(@"nextToLastWeek %d", nextToLastWeek);
NSRange range;
range = [self.calendar minimumRangeOfUnit:NSWeekOfYearCalendarUnit];
NSLog(@"minimumRangeOfUnit:[%d, %d]", range.location, range.location + range.length - 1);
range = [self.calendar maximumRangeOfUnit:NSWeekOfYearCalendarUnit];
NSLog(@"maximumRangeOfUnit:[%d, %d]", range.location, range.location + range.length - 1);
range = [self.calendar rangeOfUnit:NSWeekOfYearCalendarUnit inUnit:NSYearCalendarUnit forDate:firstOfMonth];
NSLog(@"rangeOfUnit:inUnit:[%d, %d]", range.location, range.location + range.length - 1);
}
I got this output:
2013-03-16 18:42:31.324 MyApp[95353:c07] section 480
2013-03-16 18:42:31.324 MyApp[95353:c07] firstWeek 53
2013-03-16 18:42:31.324 MyApp[95353:c07] nextToLastWeek 3
2013-03-16 18:42:31.324 MyApp[95353:c07] minimumRangeOfUnit:[1, 52]
2013-03-16 18:42:31.324 MyApp[95353:c07] maximumRangeOfUnit:[1, 53]
2013-03-16 18:42:31.324 MyApp[95353:c07] rangeOfUnit:inUnit:[0, 52]
2013-03-16 18:42:31.325 MyApp[95353:c07] section 504
2013-03-16 18:42:31.326 MyApp[95353:c07] firstWeek 52
2013-03-16 18:42:31.326 MyApp[95353:c07] nextToLastWeek 4
2013-03-16 18:42:31.326 MyApp[95353:c07] minimumRangeOfUnit:[1, 52]
2013-03-16 18:42:31.326 MyApp[95353:c07] maximumRangeOfUnit:[1, 53]
2013-03-16 18:42:31.326 MyApp[95353:c07] rangeOfUnit:inUnit:[0, 53]
Hopefully that's useful in figuring out the valid range. I also found that I can work around the problem by adding this just before the return:
if (firstWeek > nextToLastWeek)
{
// The first week must have been the end of last year.
firstWeek = 0;
}
but I'm not sure I understand what I've done well enough to say that that's fixed the problem. I could still put it in a pull request, if you'd like (I've signed the CLA for KIF - do I need to sign it again for TS?).
from objc-timessquare.
Related Issues (20)
- rendering issue with TSQTACalednarRowCell HOT 2
- Any way to change swipe length? HOT 1
- Can't Archive HOT 2
- Won't run HOT 2
- Mark Day
- UITextAlignmentCenter is deprecated
- NSDateComponents.week is deprecated
- Question]Drawing in a cell
- iOS 8 update HOT 1
- Disable some dates
- Monday as first day of week HOT 1
- Calendar not rendered HOT 1
- I want to select multiple dates like "TimesSquare for Android" can your help me HOT 1
- how to close TimesSquare? HOT 1
- Change start day HOT 5
- how to displayOnly
- Highlight multiple dates HOT 2
- One month frame size
- No access to tableView in Swift
- I can't run this app.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from objc-timessquare.