Bug 124379 - Reimplement getDayBoundaries using NSCalendar
Summary: Reimplement getDayBoundaries using NSCalendar
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Anders Carlsson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-14 13:31 PST by Anders Carlsson
Modified: 2013-11-14 14:00 PST (History)
0 users

See Also:


Attachments
Patch (2.17 KB, patch)
2013-11-14 13:32 PST, Anders Carlsson
no flags Details | Formatted Diff | Diff
Patch (2.08 KB, patch)
2013-11-14 13:46 PST, Anders Carlsson
no flags Details | Formatted Diff | Diff
Patch (2.13 KB, patch)
2013-11-14 13:55 PST, Anders Carlsson
mitz: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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>