add issing date components.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@36012 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2013-01-24 09:15:53 +00:00
parent dde8376be9
commit d005afdc13
2 changed files with 29 additions and 16 deletions

View file

@ -1,3 +1,8 @@
2013-01-24 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSCalendar.m: (-[dateByAddingComponents:toDate:options:]),
([-dateFromComponents:]) add support for missing components.
2013-01-22 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSPredicate.m: Fixup parsing of function expressions.

View file

@ -334,14 +334,22 @@ static NSRecursiveLock *classLock = nil;
ucal_roll (_cal, c, n, &err); \
else \
ucal_add (_cal, c, n, &err);
if ((amount = (int32_t)[comps day]) != NSUndefinedDateComponent)
{
_ADD_COMPONENT(UCAL_DAY_OF_MONTH, amount);
}
if ((amount = (int32_t)[comps era]) != NSUndefinedDateComponent)
{
_ADD_COMPONENT(UCAL_ERA, amount);
}
if ((amount = (int32_t)[comps year]) != NSUndefinedDateComponent)
{
_ADD_COMPONENT(UCAL_YEAR, amount);
}
if ((amount = (int32_t)[comps month]) != NSUndefinedDateComponent)
{
_ADD_COMPONENT(UCAL_MONTH, amount);
}
if ((amount = (int32_t)[comps day]) != NSUndefinedDateComponent)
{
_ADD_COMPONENT(UCAL_DAY_OF_MONTH, amount);
}
if ((amount = (int32_t)[comps hour]) != NSUndefinedDateComponent)
{
_ADD_COMPONENT(UCAL_HOUR_OF_DAY, amount);
@ -350,10 +358,6 @@ static NSRecursiveLock *classLock = nil;
{
_ADD_COMPONENT(UCAL_MINUTE, amount);
}
if ((amount = (int32_t)[comps month]) != NSUndefinedDateComponent)
{
_ADD_COMPONENT(UCAL_MONTH, amount);
}
if ((amount = (int32_t)[comps second]) != NSUndefinedDateComponent)
{
_ADD_COMPONENT(UCAL_SECOND, amount);
@ -388,14 +392,22 @@ static NSRecursiveLock *classLock = nil;
[self _resetCalendar];
ucal_clear (_cal);
if ((amount = (int32_t)[comps day]) != NSUndefinedDateComponent)
{
ucal_set (_cal, UCAL_DAY_OF_MONTH, amount);
}
if ((amount = (int32_t)[comps era]) != NSUndefinedDateComponent)
{
ucal_set (_cal, UCAL_ERA, amount);
}
if ((amount = (int32_t)[comps year]) != NSUndefinedDateComponent)
{
ucal_set (_cal, UCAL_YEAR, amount);
}
if ((amount = (int32_t)[comps month]) != NSUndefinedDateComponent)
{
ucal_set (_cal, UCAL_MONTH, amount);
}
if ((amount = (int32_t)[comps day]) != NSUndefinedDateComponent)
{
ucal_set (_cal, UCAL_DAY_OF_MONTH, amount);
}
if ((amount = (int32_t)[comps hour]) != NSUndefinedDateComponent)
{
ucal_set (_cal, UCAL_HOUR_OF_DAY, amount);
@ -404,10 +416,6 @@ static NSRecursiveLock *classLock = nil;
{
ucal_set (_cal, UCAL_MINUTE, amount);
}
if ((amount = (int32_t)[comps month]) != NSUndefinedDateComponent)
{
ucal_set (_cal, UCAL_MONTH, amount);
}
if ((amount = (int32_t)[comps second]) != NSUndefinedDateComponent)
{
ucal_set (_cal, UCAL_SECOND, amount);