mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Add support for NSDate constants in NSPredicate.
This commit is contained in:
parent
36d00c7f00
commit
88f5cc2444
2 changed files with 24 additions and 0 deletions
|
@ -1,3 +1,7 @@
|
|||
2020-01-12 Fred Kiefer <fredkiefer@gmx.de>
|
||||
|
||||
* Source/NSPredicate.m: Add support for NSDate constants.
|
||||
|
||||
2020-01-12 Fred Kiefer <fredkiefer@gmx.de>
|
||||
|
||||
* Source/NSKeyValueObserving.m: Implement two missing KVO methods
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#import "Foundation/NSPredicate.h"
|
||||
|
||||
#import "Foundation/NSArray.h"
|
||||
#import "Foundation/NSDate.h"
|
||||
#import "Foundation/NSDictionary.h"
|
||||
#import "Foundation/NSEnumerator.h"
|
||||
#import "Foundation/NSException.h"
|
||||
|
@ -1313,6 +1314,11 @@ GSICUStringMatchesRegex(NSString *string, NSString *regex, NSStringCompareOption
|
|||
GSPropertyListMake(_obj, nil, NO, YES, 2, &result);
|
||||
return result;
|
||||
}
|
||||
else if ([_obj isKindOfClass: [NSDate class]])
|
||||
{
|
||||
return [NSString stringWithFormat: @"CAST(%15.6f, \"NSDate\")",
|
||||
[(NSDate*)_obj timeIntervalSinceReferenceDate]];
|
||||
}
|
||||
return [_obj description];
|
||||
}
|
||||
|
||||
|
@ -1720,6 +1726,20 @@ GSICUStringMatchesRegex(NSString *string, NSString *regex, NSStringCompareOption
|
|||
return [NSNumber numberWithDouble: sum];
|
||||
}
|
||||
|
||||
- (id) _eval_CAST: (NSArray *)expressions
|
||||
{
|
||||
id left = [expressions objectAtIndex: 0];
|
||||
id right = [expressions objectAtIndex: 1];
|
||||
|
||||
if ([right isEqualToString: @"NSDate"])
|
||||
{
|
||||
return [[NSDate alloc] initWithTimeIntervalSinceReferenceDate: [left doubleValue]];
|
||||
}
|
||||
|
||||
NSLog(@"Cast to unknown type %@", right);
|
||||
return nil;
|
||||
}
|
||||
|
||||
// add arithmetic functions: average, median, mode, stddev, sqrt, log, ln, exp, floor, ceiling, abs, trunc, random, randomn, now
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue