Bug 124379

Summary: Reimplement getDayBoundaries using NSCalendar
Product: WebKit Reporter: Anders Carlsson <andersca>
Component: New BugsAssignee: Anders Carlsson <andersca>
Status: RESOLVED FIXED    
Severity: Normal    
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch mitz: review+

Description Anders Carlsson 2013-11-14 13:31:54 PST
Reimplement getDayBoundaries using NSCalendar on 10.9
Comment 1 Anders Carlsson 2013-11-14 13:32:46 PST
Created attachment 216973 [details]
Patch
Comment 2 mitz 2013-11-14 13:37:05 PST
Comment on attachment 216973 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=216973&action=review

> Source/WebKit/mac/History/WebHistory.mm:164
> +    NSDate *beginningOfDayDate = [calendar startOfDayForDate:date];
> +    beginningOfDay = beginningOfDayDate.timeIntervalSinceReferenceDate;
> +
> +    NSDate *beginningOfNextDayDate = [calendar dateByAddingUnit:NSCalendarUnitDay value:1 toDate:beginningOfDayDate options:0];

I believe you can do this with a single method call to -[NSCalendar rangeOfUnit:startDate:interval:forDate:]. Seems wasteful to do two.
Comment 3 Anders Carlsson 2013-11-14 13:46:50 PST
Created attachment 216975 [details]
Patch
Comment 4 mitz 2013-11-14 13:50:22 PST
Comment on attachment 216975 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=216975&action=review

> Source/WebKit/mac/History/WebHistory.mm:158
> +    NSCalendar *calendar = [NSCalendar calendarWithIdentifier:NSCalendarIdentifierGregorian];

I believe NSCalendarIdentifierGregorian and NSCalendarUnitDay aren’t available in some of the SDKs we target. You may need to add #ifdefs around some things here.
Comment 5 Anders Carlsson 2013-11-14 13:55:41 PST
Created attachment 216977 [details]
Patch
Comment 6 Anders Carlsson 2013-11-14 14:00:55 PST
Committed r159311: <http://trac.webkit.org/changeset/159311>