Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Source/CFCalendar.c
Original file line number Diff line number Diff line change
Expand Up @@ -832,13 +832,13 @@ CFRange
CFCalendarGetMaximumRangeOfUnit (CFCalendarRef cal, CFCalendarUnit unit)
{
return CFCalendarGetMinMaxRangeOfUnit (cal, unit,
UCAL_GREATEST_MINIMUM, UCAL_LEAST_MAXIMUM);
UCAL_MINIMUM, UCAL_MAXIMUM);
}

CFRange
CFCalendarGetMinimumRangeOfUnit (CFCalendarRef cal, CFCalendarUnit unit)
{
return CFCalendarGetMinMaxRangeOfUnit (cal, unit,
UCAL_MINIMUM, UCAL_MAXIMUM);
UCAL_GREATEST_MINIMUM, UCAL_LEAST_MAXIMUM);
}

28 changes: 28 additions & 0 deletions Tests/CFCalendar/ranges.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "CoreFoundation/CFCalendar.h"
#include "CoreFoundation/CFTimeZone.h"
#include "../CFTesting.h"

/* CFCalendarGetMaximumRangeOfUnit is the widest a unit can be, and
CFCalendarGetMinimumRangeOfUnit is the narrowest. */

int main (void)
{
CFTimeZoneRef gmt = CFTimeZoneCreateWithTimeIntervalFromGMT (NULL, 0.0);
CFCalendarRef cal = CFCalendarCreateWithIdentifier (NULL,
kCFGregorianCalendar);
CFRange r;

CFCalendarSetTimeZone (cal, gmt);

r = CFCalendarGetMaximumRangeOfUnit (cal, kCFCalendarUnitDay);
PASS_CF (r.location == 1 && r.length == 31,
"The maximum day-of-month range is 1 to 31.");

r = CFCalendarGetMinimumRangeOfUnit (cal, kCFCalendarUnitDay);
PASS_CF (r.location == 1 && r.length == 28,
"The minimum day-of-month range is 1 to 28.");

CFRelease (cal);
CFRelease (gmt);
return 0;
}
Loading