mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-25 01:31:08 +00:00
Merge branch 'UnitsOfMeasure' of github.com:gnustep/libs-base into UnitsOfMeasure
This commit is contained in:
commit
9f36d5107e
17 changed files with 2429 additions and 439 deletions
|
@ -55,12 +55,14 @@
|
|||
#import <Foundation/NSConnection.h>
|
||||
#import <Foundation/NSData.h>
|
||||
#import <Foundation/NSDateFormatter.h>
|
||||
#import <Foundation/NSDateInterval.h>
|
||||
#import <Foundation/NSDate.h>
|
||||
#import <Foundation/NSDecimalNumber.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSDistantObject.h>
|
||||
#import <Foundation/NSDistributedLock.h>
|
||||
#import <Foundation/NSDistributedNotificationCenter.h>
|
||||
#import <Foundation/NSEnergyFormatter.h>
|
||||
#import <Foundation/NSEnumerator.h>
|
||||
#import <Foundation/NSError.h>
|
||||
#import <Foundation/NSException.h>
|
||||
|
@ -86,6 +88,7 @@
|
|||
#import <Foundation/NSKeyedArchiver.h>
|
||||
#import <Foundation/NSKeyValueCoding.h>
|
||||
#import <Foundation/NSKeyValueObserving.h>
|
||||
#import <Foundation/NSLengthFormatter.h>
|
||||
#import <Foundation/NSLock.h>
|
||||
#import <Foundation/NSLocale.h>
|
||||
#import <Foundation/NSMapTable.h>
|
||||
|
@ -138,6 +141,7 @@
|
|||
#import <Foundation/NSTimeZone.h>
|
||||
#import <Foundation/NSUbiquitousKeyValueStore.h>
|
||||
#import <Foundation/NSUndoManager.h>
|
||||
#import <Foundation/NSUnit.h>
|
||||
#import <Foundation/NSURLAuthenticationChallenge.h>
|
||||
#import <Foundation/NSURLCache.h>
|
||||
#import <Foundation/NSURLConnection.h>
|
||||
|
|
|
@ -20,9 +20,6 @@ NSAppleEventDescriptor.h
|
|||
NSAppleEventManager.h
|
||||
NSBackgroundActivityScheduler.h
|
||||
NSDateComponentsFormatter.h
|
||||
NSDateIntervalFormatter.h
|
||||
NSDateInterval.h
|
||||
NSEnergyFormatter.h
|
||||
NSExtensionContext.h
|
||||
NSExtensionItem.h
|
||||
NSExtensionRequestHandling.h
|
||||
|
@ -30,44 +27,10 @@ NSHFSFileTypes.h
|
|||
NSISO8601DateFormatter.h
|
||||
NSItemProvider.h
|
||||
NSItemProviderReadingWriting.h
|
||||
NSLengthFormatter.h
|
||||
NSLinguisticTagger.h
|
||||
NSMassFormatter.h
|
||||
NSMeasurementFormatter.h
|
||||
NSMeasurement.h
|
||||
NSMetadataAttributes.h
|
||||
NSObjectScripting.h
|
||||
NSOrthography.h
|
||||
NSUnit.h
|
||||
NSUserActivity.h
|
||||
NSXPCConnection.h
|
||||
-------------------------------------------------------------
|
||||
Foundation:
|
||||
==
|
||||
FoundationLegacySwiftCompatibility.h
|
||||
NSAppleEventDescriptor.h
|
||||
NSAppleEventManager.h
|
||||
NSBackgroundActivityScheduler.h
|
||||
NSDateComponentsFormatter.h
|
||||
NSDateIntervalFormatter.h
|
||||
NSDateInterval.h
|
||||
NSEnergyFormatter.h
|
||||
NSExtensionContext.h
|
||||
NSExtensionItem.h
|
||||
NSExtensionRequestHandling.h
|
||||
NSHFSFileTypes.h
|
||||
NSISO8601DateFormatter.h
|
||||
NSItemProvider.h
|
||||
NSItemProviderReadingWriting.h
|
||||
NSLengthFormatter.h
|
||||
NSLinguisticTagger.h
|
||||
NSMassFormatter.h
|
||||
NSMeasurementFormatter.h
|
||||
NSMeasurement.h
|
||||
NSMetadataAttributes.h
|
||||
NSObjectScripting.h
|
||||
NSOrthography.h
|
||||
NSUnit.h
|
||||
NSUserActivity.h
|
||||
NSXPCConnection.h
|
||||
|
||||
|
|
86
Headers/Foundation/NSDateInterval.h
Normal file
86
Headers/Foundation/NSDateInterval.h
Normal file
|
@ -0,0 +1,86 @@
|
|||
|
||||
/* Definition of class NSDateInterval
|
||||
Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
|
||||
By: Gregory Casamento <greg.casamento@gmail.com>
|
||||
Date: Wed Oct 9 16:24:13 EDT 2019
|
||||
|
||||
This file is part of the GNUstep Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#ifndef _NSDateInterval_h_GNUSTEP_BASE_INCLUDE
|
||||
#define _NSDateInterval_h_GNUSTEP_BASE_INCLUDE
|
||||
|
||||
#include <Foundation/NSObject.h>
|
||||
#include <Foundation/NSDate.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_12, GS_API_LATEST)
|
||||
|
||||
@interface NSDateInterval : NSObject <NSCoding, NSCopying>
|
||||
{
|
||||
NSTimeInterval _duration;
|
||||
NSDate *_startDate;
|
||||
NSDate *_endDate;
|
||||
}
|
||||
|
||||
// Init
|
||||
- (instancetype) init;
|
||||
|
||||
- (instancetype) initWithStartDate: (NSDate *)startDate
|
||||
duration: (NSTimeInterval)duration;
|
||||
|
||||
- (instancetype) initWithStartDate: (NSDate *)startDate
|
||||
endDate: (NSDate *)endDate;
|
||||
|
||||
// Access
|
||||
- (NSDate *) startDate;
|
||||
- (void) setStartDate: (NSDate *)startDate;
|
||||
|
||||
- (NSDate *) endDate;
|
||||
- (void) setEndDate: (NSDate *)endDate;
|
||||
|
||||
- (NSTimeInterval)duration;
|
||||
- (void) setDuration: (NSTimeInterval)duration;
|
||||
|
||||
// Compare
|
||||
- (NSComparisonResult) compare: (NSDateInterval *)dateInterval;
|
||||
|
||||
- (BOOL) isEqualToDateInterval: (NSDateInterval *)dateInterval;
|
||||
|
||||
// Determine
|
||||
- (BOOL) intersectsDateInterval: (NSDateInterval *)dateInterval;
|
||||
|
||||
- (NSDateInterval *) intersectionWithDateInterval: (NSDateInterval *)dateInterval;
|
||||
|
||||
// Contain
|
||||
- (BOOL) containsDate: (NSDate *)date;
|
||||
|
||||
@end
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* GS_API_MACOSX */
|
||||
|
||||
#endif /* _NSDateInterval_h_GNUSTEP_BASE_INCLUDE */
|
||||
|
48
Headers/Foundation/NSDateIntervalFormatter.h
Normal file
48
Headers/Foundation/NSDateIntervalFormatter.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
|
||||
/* Definition of class NSDateIntervalFormatter
|
||||
Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
|
||||
By: heron
|
||||
Date: Wed Oct 9 16:23:55 EDT 2019
|
||||
|
||||
This file is part of the GNUstep Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#ifndef _NSDateIntervalFormatter_h_GNUSTEP_BASE_INCLUDE
|
||||
#define _NSDateIntervalFormatter_h_GNUSTEP_BASE_INCLUDE
|
||||
|
||||
#include <Foundation/NSFormatter.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_0, GS_API_LATEST)
|
||||
|
||||
@interface NSDateIntervalFormatter : NSFormatter
|
||||
|
||||
@end
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* GS_API_MACOSX */
|
||||
|
||||
#endif /* _NSDateIntervalFormatter_h_GNUSTEP_BASE_INCLUDE */
|
||||
|
48
Headers/Foundation/NSEnergyFormatter.h
Normal file
48
Headers/Foundation/NSEnergyFormatter.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
|
||||
/* Definition of class NSEnergyFormatter
|
||||
Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
|
||||
By: heron
|
||||
Date: Tue Oct 8 13:30:10 EDT 2019
|
||||
|
||||
This file is part of the GNUstep Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#ifndef _NSEnergyFormatter_h_GNUSTEP_BASE_INCLUDE
|
||||
#define _NSEnergyFormatter_h_GNUSTEP_BASE_INCLUDE
|
||||
|
||||
#include <Foundation/NSFormatter.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_0, GS_API_LATEST)
|
||||
|
||||
@interface NSEnergyFormatter : NSFormatter
|
||||
|
||||
@end
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* GS_API_MACOSX */
|
||||
|
||||
#endif /* _NSEnergyFormatter_h_GNUSTEP_BASE_INCLUDE */
|
||||
|
48
Headers/Foundation/NSLengthFormatter.h
Normal file
48
Headers/Foundation/NSLengthFormatter.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
|
||||
/* Definition of class NSLengthFormatter
|
||||
Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
|
||||
By: heron
|
||||
Date: Tue Oct 8 13:30:33 EDT 2019
|
||||
|
||||
This file is part of the GNUstep Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#ifndef _NSLengthFormatter_h_GNUSTEP_BASE_INCLUDE
|
||||
#define _NSLengthFormatter_h_GNUSTEP_BASE_INCLUDE
|
||||
|
||||
#include <Foundation/NSFormatter.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_0, GS_API_LATEST)
|
||||
|
||||
@interface NSLengthFormatter : NSFormatter
|
||||
|
||||
@end
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* GS_API_MACOSX */
|
||||
|
||||
#endif /* _NSLengthFormatter_h_GNUSTEP_BASE_INCLUDE */
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
/* Definition of class NSMeasurement
|
||||
Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
|
||||
By: heron
|
||||
By: Gregory John Casamento <greg.casamento@gmail.com>
|
||||
Date: Mon Sep 30 15:58:21 EDT 2019
|
||||
|
||||
This file is part of the GNUstep Library.
|
||||
|
@ -27,6 +27,7 @@
|
|||
#define _NSMeasurement_h_GNUSTEP_BASE_INCLUDE
|
||||
|
||||
#include <Foundation/NSObject.h>
|
||||
#include <Foundation/NSUnit.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
|
@ -34,7 +35,33 @@ extern "C" {
|
|||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_0, GS_API_LATEST)
|
||||
|
||||
@interface NSMeasurement : NSObject
|
||||
@class NSUnit;
|
||||
|
||||
@interface NSMeasurement : NSObject <NSCopying, NSCoding>
|
||||
{
|
||||
NSUnit *_unit;
|
||||
double _doubleValue;
|
||||
}
|
||||
|
||||
// Creating Measurements
|
||||
- (instancetype)initWithDoubleValue: (double)doubleValue
|
||||
unit: (NSUnit *)unit;
|
||||
|
||||
|
||||
// Accessing unit and value
|
||||
- (NSUnit *) unit;
|
||||
|
||||
- (double) doubleValue;
|
||||
|
||||
// Conversion
|
||||
- (BOOL) canBeConvertedToUnit: (NSUnit *)unit;
|
||||
|
||||
- (NSMeasurement *)measurementByConvertingToUnit:(NSUnit *)unit;
|
||||
|
||||
// Operating
|
||||
- (NSMeasurement *)measurementByAddingMeasurement:(NSMeasurement *)measurement;
|
||||
|
||||
- (NSMeasurement *)measurementBySubtractingMeasurement:(NSMeasurement *)measurement;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -26,15 +26,47 @@
|
|||
#ifndef _NSMeasurementFormatter_h_GNUSTEP_BASE_INCLUDE
|
||||
#define _NSMeasurementFormatter_h_GNUSTEP_BASE_INCLUDE
|
||||
|
||||
#include <Foundation/NSObject.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <Foundation/NSObject.h>
|
||||
#include <Foundation/NSFormatter.h>
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_0, GS_API_LATEST)
|
||||
@class NSLocale, NSMeasurement, NSNumberFormatter, NSUnit;
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_10, GS_API_LATEST)
|
||||
|
||||
@interface NSMeasurementFormatter : NSObject
|
||||
enum {
|
||||
NSMeasurementFormatterUnitOptionsProvidedUnit = (1UL << 0),
|
||||
NSMeasurementFormatterUnitOptionsNaturalScale = (1UL << 1),
|
||||
NSMeasurementFormatterUnitOptionsTemperatureWithoutUnit = (1UL << 2),
|
||||
};
|
||||
typedef NSUInteger NSMeasurementFormatterUnitOptions;
|
||||
|
||||
@interface NSMeasurementFormatter : NSFormatter <NSCoding>
|
||||
{
|
||||
NSMeasurementFormatterUnitOptions _unitOptions;
|
||||
NSFormattingUnitStyle _unitStyle;
|
||||
NSLocale *_locale;
|
||||
NSNumberFormatter *_numberFormatter;
|
||||
}
|
||||
|
||||
- (NSMeasurementFormatterUnitOptions) unitOptions;
|
||||
- (void) setUnitOptions: (NSMeasurementFormatterUnitOptions) unitOptions;
|
||||
|
||||
- (NSFormattingUnitStyle) unitStyle;
|
||||
- (void) setUnitStyle: (NSFormattingUnitStyle)style;
|
||||
|
||||
- (NSLocale *) locale;
|
||||
- (void) setLocale: (NSLocale *)locale;
|
||||
|
||||
- (NSNumberFormatter *) numberFormatter;
|
||||
- (void) setNumberFormatter: (NSNumberFormatter *)numberFormatter;
|
||||
|
||||
- (NSString *)stringFromMeasurement: (NSMeasurement *)measurement;
|
||||
|
||||
- (NSString *)stringFromUnit: (NSUnit *)unit;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ extern "C" {
|
|||
// Dimension using units....
|
||||
@interface NSDimension : NSUnit <NSCoding>
|
||||
{
|
||||
NSUInteger _reserved;
|
||||
double _value;
|
||||
NSUnitConverter *_converter;
|
||||
}
|
||||
|
||||
|
@ -84,8 +84,8 @@ extern "C" {
|
|||
Base unit - metersPerSecondSquared
|
||||
*/
|
||||
|
||||
- (NSUnitAcceleration *) metersPerSecondSquared;
|
||||
- (NSUnitAcceleration *) gravity;
|
||||
+ (NSUnitAcceleration *) metersPerSecondSquared;
|
||||
+ (NSUnitAcceleration *) gravity;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -94,12 +94,12 @@ extern "C" {
|
|||
Base unit - degrees
|
||||
*/
|
||||
|
||||
- (NSUnitAngle *) degrees;
|
||||
- (NSUnitAngle *) arcMinutes;
|
||||
- (NSUnitAngle *) arcSeconds;
|
||||
- (NSUnitAngle *) radians;
|
||||
- (NSUnitAngle *) gradians;
|
||||
- (NSUnitAngle *) revolutions;
|
||||
+ (NSUnitAngle *) degrees;
|
||||
+ (NSUnitAngle *) arcMinutes;
|
||||
+ (NSUnitAngle *) arcSeconds;
|
||||
+ (NSUnitAngle *) radians;
|
||||
+ (NSUnitAngle *) gradians;
|
||||
+ (NSUnitAngle *) revolutions;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -108,20 +108,20 @@ extern "C" {
|
|||
Base unit - squareMeters
|
||||
*/
|
||||
|
||||
- (NSUnitArea *) squareMegameters;
|
||||
- (NSUnitArea *) squareKilometers;
|
||||
- (NSUnitArea *) squareMeters;
|
||||
- (NSUnitArea *) squareCentimeters;
|
||||
- (NSUnitArea *) squareMillimeters;
|
||||
- (NSUnitArea *) squareMicrometers;
|
||||
- (NSUnitArea *) squareNanometers;
|
||||
- (NSUnitArea *) squareInches;
|
||||
- (NSUnitArea *) squareFeet;
|
||||
- (NSUnitArea *) squareYards;
|
||||
- (NSUnitArea *) squareMiles;
|
||||
- (NSUnitArea *) acres;
|
||||
- (NSUnitArea *) ares;
|
||||
- (NSUnitArea *) hectares;
|
||||
+ (NSUnitArea *) squareMegameters;
|
||||
+ (NSUnitArea *) squareKilometers;
|
||||
+ (NSUnitArea *) squareMeters;
|
||||
+ (NSUnitArea *) squareCentimeters;
|
||||
+ (NSUnitArea *) squareMillimeters;
|
||||
+ (NSUnitArea *) squareMicrometers;
|
||||
+ (NSUnitArea *) squareNanometers;
|
||||
+ (NSUnitArea *) squareInches;
|
||||
+ (NSUnitArea *) squareFeet;
|
||||
+ (NSUnitArea *) squareYards;
|
||||
+ (NSUnitArea *) squareMiles;
|
||||
+ (NSUnitArea *) acres;
|
||||
+ (NSUnitArea *) ares;
|
||||
+ (NSUnitArea *) hectares;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -130,8 +130,8 @@ extern "C" {
|
|||
Base unit - gramsPerLiter
|
||||
*/
|
||||
|
||||
- (NSUnitConcentrationMass *) gramsPerLiter;
|
||||
- (NSUnitConcentrationMass *) milligramsPerDeciliter;
|
||||
+ (NSUnitConcentrationMass *) gramsPerLiter;
|
||||
+ (NSUnitConcentrationMass *) milligramsPerDeciliter;
|
||||
|
||||
+ (NSUnitConcentrationMass *) millimolesPerLiterWithGramsPerMole:(double)gramsPerMole;
|
||||
|
||||
|
@ -141,7 +141,7 @@ extern "C" {
|
|||
/*
|
||||
Base unit - partsPerMillion
|
||||
*/
|
||||
- (NSUnitDispersion *) partsPerMillion;
|
||||
+ (NSUnitDispersion *) partsPerMillion;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -150,9 +150,9 @@ extern "C" {
|
|||
Base unit - seconds
|
||||
*/
|
||||
|
||||
- (NSUnitDuration *) seconds;
|
||||
- (NSUnitDuration *) minutes;
|
||||
- (NSUnitDuration *) hours;
|
||||
+ (NSUnitDuration *) seconds;
|
||||
+ (NSUnitDuration *) minutes;
|
||||
+ (NSUnitDuration *) hours;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -161,12 +161,12 @@ extern "C" {
|
|||
Base unit - coulombs
|
||||
*/
|
||||
|
||||
- (NSUnitElectricCharge *) coulombs;
|
||||
- (NSUnitElectricCharge *) megaampereHours;
|
||||
- (NSUnitElectricCharge *) kiloampereHours;
|
||||
- (NSUnitElectricCharge *) ampereHours;
|
||||
- (NSUnitElectricCharge *) milliampereHours;
|
||||
- (NSUnitElectricCharge *) microampereHours;
|
||||
+ (NSUnitElectricCharge *) coulombs;
|
||||
+ (NSUnitElectricCharge *) megaampereHours;
|
||||
+ (NSUnitElectricCharge *) kiloampereHours;
|
||||
+ (NSUnitElectricCharge *) ampereHours;
|
||||
+ (NSUnitElectricCharge *) milliampereHours;
|
||||
+ (NSUnitElectricCharge *) microampereHours;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -175,11 +175,11 @@ extern "C" {
|
|||
Base unit - amperes
|
||||
*/
|
||||
|
||||
- (NSUnitElectricCurrent *) megaamperes;
|
||||
- (NSUnitElectricCurrent *) kiloamperes;
|
||||
- (NSUnitElectricCurrent *) amperes;
|
||||
- (NSUnitElectricCurrent *) milliamperes;
|
||||
- (NSUnitElectricCurrent *) microamperes;
|
||||
+ (NSUnitElectricCurrent *) megaamperes;
|
||||
+ (NSUnitElectricCurrent *) kiloamperes;
|
||||
+ (NSUnitElectricCurrent *) amperes;
|
||||
+ (NSUnitElectricCurrent *) milliamperes;
|
||||
+ (NSUnitElectricCurrent *) microamperes;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -188,11 +188,11 @@ extern "C" {
|
|||
Base unit - volts
|
||||
*/
|
||||
|
||||
- (NSUnitElectricPotentialDifference *) megavolts;
|
||||
- (NSUnitElectricPotentialDifference *) kilovolts;
|
||||
- (NSUnitElectricPotentialDifference *) volts;
|
||||
- (NSUnitElectricPotentialDifference *) millivolts;
|
||||
- (NSUnitElectricPotentialDifference *) microvolts;
|
||||
+ (NSUnitElectricPotentialDifference *) megavolts;
|
||||
+ (NSUnitElectricPotentialDifference *) kilovolts;
|
||||
+ (NSUnitElectricPotentialDifference *) volts;
|
||||
+ (NSUnitElectricPotentialDifference *) millivolts;
|
||||
+ (NSUnitElectricPotentialDifference *) microvolts;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -201,11 +201,11 @@ extern "C" {
|
|||
Base unit - ohms
|
||||
*/
|
||||
|
||||
- (NSUnitElectricResistance *) megaohms;
|
||||
- (NSUnitElectricResistance *) kiloohms;
|
||||
- (NSUnitElectricResistance *) ohms;
|
||||
- (NSUnitElectricResistance *) milliohms;
|
||||
- (NSUnitElectricResistance *) microohms;
|
||||
+ (NSUnitElectricResistance *) megaohms;
|
||||
+ (NSUnitElectricResistance *) kiloohms;
|
||||
+ (NSUnitElectricResistance *) ohms;
|
||||
+ (NSUnitElectricResistance *) milliohms;
|
||||
+ (NSUnitElectricResistance *) microohms;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -214,11 +214,11 @@ extern "C" {
|
|||
Base unit - joules
|
||||
*/
|
||||
|
||||
- (NSUnitEnergy *) kilojoules;
|
||||
- (NSUnitEnergy *) joules;
|
||||
- (NSUnitEnergy *) kilocalories;
|
||||
- (NSUnitEnergy *) calories;
|
||||
- (NSUnitEnergy *) kilowattHours;
|
||||
+ (NSUnitEnergy *) kilojoules;
|
||||
+ (NSUnitEnergy *) joules;
|
||||
+ (NSUnitEnergy *) kilocalories;
|
||||
+ (NSUnitEnergy *) calories;
|
||||
+ (NSUnitEnergy *) kilowattHours;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -227,14 +227,14 @@ extern "C" {
|
|||
Base unit - hertz
|
||||
*/
|
||||
|
||||
- (NSUnitFrequency *) terahertz;
|
||||
- (NSUnitFrequency *) gigahertz;
|
||||
- (NSUnitFrequency *) megahertz;
|
||||
- (NSUnitFrequency *) kilohertz;
|
||||
- (NSUnitFrequency *) hertz;
|
||||
- (NSUnitFrequency *) millihertz;
|
||||
- (NSUnitFrequency *) microhertz;
|
||||
- (NSUnitFrequency *) nanohertz;
|
||||
+ (NSUnitFrequency *) terahertz;
|
||||
+ (NSUnitFrequency *) gigahertz;
|
||||
+ (NSUnitFrequency *) megahertz;
|
||||
+ (NSUnitFrequency *) kilohertz;
|
||||
+ (NSUnitFrequency *) hertz;
|
||||
+ (NSUnitFrequency *) millihertz;
|
||||
+ (NSUnitFrequency *) microhertz;
|
||||
+ (NSUnitFrequency *) nanohertz;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -243,9 +243,9 @@ extern "C" {
|
|||
Base unit - litersPer100Kilometers
|
||||
*/
|
||||
|
||||
- (NSUnitFuelEfficiency *) litersPer100Kilometers;
|
||||
- (NSUnitFuelEfficiency *) milesPerImperialGallon;
|
||||
- (NSUnitFuelEfficiency *) milesPerGallon;
|
||||
+ (NSUnitFuelEfficiency *) litersPer100Kilometers;
|
||||
+ (NSUnitFuelEfficiency *) milesPerImperialGallon;
|
||||
+ (NSUnitFuelEfficiency *) milesPerGallon;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -254,28 +254,28 @@ extern "C" {
|
|||
Base unit - meters
|
||||
*/
|
||||
|
||||
- (NSUnitLength *) megameters;
|
||||
- (NSUnitLength *) kilometers;
|
||||
- (NSUnitLength *) hectometers;
|
||||
- (NSUnitLength *) decameters;
|
||||
- (NSUnitLength *) meters;
|
||||
- (NSUnitLength *) decimeters;
|
||||
- (NSUnitLength *) centimeters;
|
||||
- (NSUnitLength *) millimeters;
|
||||
- (NSUnitLength *) micrometers;
|
||||
- (NSUnitLength *) nanometers;
|
||||
- (NSUnitLength *) picometers;
|
||||
- (NSUnitLength *) inches;
|
||||
- (NSUnitLength *) feet;
|
||||
- (NSUnitLength *) yards;
|
||||
- (NSUnitLength *) miles;
|
||||
- (NSUnitLength *) scandinavianMiles;
|
||||
- (NSUnitLength *) lightyears;
|
||||
- (NSUnitLength *) nauticalMiles;
|
||||
- (NSUnitLength *) fathoms;
|
||||
- (NSUnitLength *) furlongs;
|
||||
- (NSUnitLength *) astronomicalUnits;
|
||||
- (NSUnitLength *) parsecs;
|
||||
+ (NSUnitLength *) megameters;
|
||||
+ (NSUnitLength *) kilometers;
|
||||
+ (NSUnitLength *) hectometers;
|
||||
+ (NSUnitLength *) decameters;
|
||||
+ (NSUnitLength *) meters;
|
||||
+ (NSUnitLength *) decimeters;
|
||||
+ (NSUnitLength *) centimeters;
|
||||
+ (NSUnitLength *) millimeters;
|
||||
+ (NSUnitLength *) micrometers;
|
||||
+ (NSUnitLength *) nanometers;
|
||||
+ (NSUnitLength *) picometers;
|
||||
+ (NSUnitLength *) inches;
|
||||
+ (NSUnitLength *) feet;
|
||||
+ (NSUnitLength *) yards;
|
||||
+ (NSUnitLength *) miles;
|
||||
+ (NSUnitLength *) scandinavianMiles;
|
||||
+ (NSUnitLength *) lightyears;
|
||||
+ (NSUnitLength *) nauticalMiles;
|
||||
+ (NSUnitLength *) fathoms;
|
||||
+ (NSUnitLength *) furlongs;
|
||||
+ (NSUnitLength *) astronomicalUnits;
|
||||
+ (NSUnitLength *) parsecs;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -284,7 +284,7 @@ extern "C" {
|
|||
Base unit - lux
|
||||
*/
|
||||
|
||||
- (NSUnitIlluminance *) lux;
|
||||
+ (NSUnitIlluminance *) lux;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -293,22 +293,22 @@ extern "C" {
|
|||
Base unit - kilograms
|
||||
*/
|
||||
|
||||
- (NSUnitMass *) kilograms;
|
||||
- (NSUnitMass *) grams;
|
||||
- (NSUnitMass *) decigrams;
|
||||
- (NSUnitMass *) centigrams;
|
||||
- (NSUnitMass *) milligrams;
|
||||
- (NSUnitMass *) micrograms;
|
||||
- (NSUnitMass *) nanograms;
|
||||
- (NSUnitMass *) picograms;
|
||||
- (NSUnitMass *) ounces;
|
||||
- (NSUnitMass *) poundsMass;
|
||||
- (NSUnitMass *) stones;
|
||||
- (NSUnitMass *) metricTons;
|
||||
- (NSUnitMass *) shortTons;
|
||||
- (NSUnitMass *) carats;
|
||||
- (NSUnitMass *) ouncesTroy;
|
||||
- (NSUnitMass *) slugs;
|
||||
+ (NSUnitMass *) kilograms;
|
||||
+ (NSUnitMass *) grams;
|
||||
+ (NSUnitMass *) decigrams;
|
||||
+ (NSUnitMass *) centigrams;
|
||||
+ (NSUnitMass *) milligrams;
|
||||
+ (NSUnitMass *) micrograms;
|
||||
+ (NSUnitMass *) nanograms;
|
||||
+ (NSUnitMass *) picograms;
|
||||
+ (NSUnitMass *) ounces;
|
||||
+ (NSUnitMass *) poundsMass;
|
||||
+ (NSUnitMass *) stones;
|
||||
+ (NSUnitMass *) metricTons;
|
||||
+ (NSUnitMass *) shortTons;
|
||||
+ (NSUnitMass *) carats;
|
||||
+ (NSUnitMass *) ouncesTroy;
|
||||
+ (NSUnitMass *) slugs;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -317,17 +317,17 @@ extern "C" {
|
|||
Base unit - watts
|
||||
*/
|
||||
|
||||
- (NSUnitPower *) terawatts;
|
||||
- (NSUnitPower *) gigawatts;
|
||||
- (NSUnitPower *) megawatts;
|
||||
- (NSUnitPower *) kilowatts;
|
||||
- (NSUnitPower *) watts;
|
||||
- (NSUnitPower *) milliwatts;
|
||||
- (NSUnitPower *) microwatts;
|
||||
- (NSUnitPower *) nanowatts;
|
||||
- (NSUnitPower *) picowatts;
|
||||
- (NSUnitPower *) femtowatts;
|
||||
- (NSUnitPower *) horsepower;
|
||||
+ (NSUnitPower *) terawatts;
|
||||
+ (NSUnitPower *) gigawatts;
|
||||
+ (NSUnitPower *) megawatts;
|
||||
+ (NSUnitPower *) kilowatts;
|
||||
+ (NSUnitPower *) watts;
|
||||
+ (NSUnitPower *) milliwatts;
|
||||
+ (NSUnitPower *) microwatts;
|
||||
+ (NSUnitPower *) nanowatts;
|
||||
+ (NSUnitPower *) picowatts;
|
||||
+ (NSUnitPower *) femtowatts;
|
||||
+ (NSUnitPower *) horsepower;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -336,16 +336,16 @@ extern "C" {
|
|||
Base unit - newtonsPerMetersSquared (equivalent to 1 pascal)
|
||||
*/
|
||||
|
||||
- (NSUnitPressure *) newtonsPerMetersSquared;
|
||||
- (NSUnitPressure *) gigapascals;
|
||||
- (NSUnitPressure *) megapascals;
|
||||
- (NSUnitPressure *) kilopascals;
|
||||
- (NSUnitPressure *) hectopascals;
|
||||
- (NSUnitPressure *) inchesOfMercury;
|
||||
- (NSUnitPressure *) bars;
|
||||
- (NSUnitPressure *) millibars;
|
||||
- (NSUnitPressure *) millimetersOfMercury;
|
||||
- (NSUnitPressure *) poundsForcePerSquareInch;
|
||||
+ (NSUnitPressure *) newtonsPerMetersSquared;
|
||||
+ (NSUnitPressure *) gigapascals;
|
||||
+ (NSUnitPressure *) megapascals;
|
||||
+ (NSUnitPressure *) kilopascals;
|
||||
+ (NSUnitPressure *) hectopascals;
|
||||
+ (NSUnitPressure *) inchesOfMercury;
|
||||
+ (NSUnitPressure *) bars;
|
||||
+ (NSUnitPressure *) millibars;
|
||||
+ (NSUnitPressure *) millimetersOfMercury;
|
||||
+ (NSUnitPressure *) poundsForcePerSquareInch;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -354,10 +354,10 @@ extern "C" {
|
|||
Base unit - metersPerSecond
|
||||
*/
|
||||
|
||||
- (NSUnitSpeed *) metersPerSecond;
|
||||
- (NSUnitSpeed *) kilometersPerHour;
|
||||
- (NSUnitSpeed *) milesPerHour;
|
||||
- (NSUnitSpeed *) knots;
|
||||
+ (NSUnitSpeed *) metersPerSecond;
|
||||
+ (NSUnitSpeed *) kilometersPerHour;
|
||||
+ (NSUnitSpeed *) milesPerHour;
|
||||
+ (NSUnitSpeed *) knots;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -365,9 +365,9 @@ extern "C" {
|
|||
/*
|
||||
Base unit - kelvin
|
||||
*/
|
||||
- (NSUnitTemperature *) kelvin;
|
||||
- (NSUnitTemperature *) celsius;
|
||||
- (NSUnitTemperature *) fahrenheit;
|
||||
+ (NSUnitTemperature *) kelvin;
|
||||
+ (NSUnitTemperature *) celsius;
|
||||
+ (NSUnitTemperature *) fahrenheit;
|
||||
|
||||
|
||||
@end
|
||||
|
@ -377,37 +377,37 @@ extern "C" {
|
|||
Base unit - liters
|
||||
*/
|
||||
|
||||
- (NSUnitVolume *) megaliters;
|
||||
- (NSUnitVolume *) kiloliters;
|
||||
- (NSUnitVolume *) liters;
|
||||
- (NSUnitVolume *) deciliters;
|
||||
- (NSUnitVolume *) centiliters;
|
||||
- (NSUnitVolume *) milliliters;
|
||||
- (NSUnitVolume *) cubicKilometers;
|
||||
- (NSUnitVolume *) cubicMeters;
|
||||
- (NSUnitVolume *) cubicDecimeters;
|
||||
- (NSUnitVolume *) cubicCentimeters;
|
||||
- (NSUnitVolume *) cubicMillimeters;
|
||||
- (NSUnitVolume *) cubicInches;
|
||||
- (NSUnitVolume *) cubicFeet;
|
||||
- (NSUnitVolume *) cubicYards;
|
||||
- (NSUnitVolume *) cubicMiles;
|
||||
- (NSUnitVolume *) acreFeet;
|
||||
- (NSUnitVolume *) bushels;
|
||||
- (NSUnitVolume *) teaspoons;
|
||||
- (NSUnitVolume *) tablespoons;
|
||||
- (NSUnitVolume *) fluidOunces;
|
||||
- (NSUnitVolume *) cups;
|
||||
- (NSUnitVolume *) pints;
|
||||
- (NSUnitVolume *) quarts;
|
||||
- (NSUnitVolume *) gallons;
|
||||
- (NSUnitVolume *) imperialTeaspoons;
|
||||
- (NSUnitVolume *) imperialTablespoons;
|
||||
- (NSUnitVolume *) imperialFluidOunces;
|
||||
- (NSUnitVolume *) imperialPints;
|
||||
- (NSUnitVolume *) imperialQuarts;
|
||||
- (NSUnitVolume *) imperialGallons;
|
||||
- (NSUnitVolume *) metricCups;
|
||||
+ (NSUnitVolume *) megaliters;
|
||||
+ (NSUnitVolume *) kiloliters;
|
||||
+ (NSUnitVolume *) liters;
|
||||
+ (NSUnitVolume *) deciliters;
|
||||
+ (NSUnitVolume *) centiliters;
|
||||
+ (NSUnitVolume *) milliliters;
|
||||
+ (NSUnitVolume *) cubicKilometers;
|
||||
+ (NSUnitVolume *) cubicMeters;
|
||||
+ (NSUnitVolume *) cubicDecimeters;
|
||||
+ (NSUnitVolume *) cubicCentimeters;
|
||||
+ (NSUnitVolume *) cubicMillimeters;
|
||||
+ (NSUnitVolume *) cubicInches;
|
||||
+ (NSUnitVolume *) cubicFeet;
|
||||
+ (NSUnitVolume *) cubicYards;
|
||||
+ (NSUnitVolume *) cubicMiles;
|
||||
+ (NSUnitVolume *) acreFeet;
|
||||
+ (NSUnitVolume *) bushels;
|
||||
+ (NSUnitVolume *) teaspoons;
|
||||
+ (NSUnitVolume *) tablespoons;
|
||||
+ (NSUnitVolume *) fluidOunces;
|
||||
+ (NSUnitVolume *) cups;
|
||||
+ (NSUnitVolume *) pints;
|
||||
+ (NSUnitVolume *) quarts;
|
||||
+ (NSUnitVolume *) gallons;
|
||||
+ (NSUnitVolume *) imperialTeaspoons;
|
||||
+ (NSUnitVolume *) imperialTablespoons;
|
||||
+ (NSUnitVolume *) imperialFluidOunces;
|
||||
+ (NSUnitVolume *) imperialPints;
|
||||
+ (NSUnitVolume *) imperialQuarts;
|
||||
+ (NSUnitVolume *) imperialGallons;
|
||||
+ (NSUnitVolume *) metricCups;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -213,6 +213,7 @@ NSConnection.m \
|
|||
NSData.m \
|
||||
NSDate.m \
|
||||
NSDateFormatter.m \
|
||||
NSDateInterval.m \
|
||||
NSDebug.m \
|
||||
NSDecimal.m \
|
||||
NSDecimalNumber.m \
|
||||
|
@ -220,6 +221,7 @@ NSDictionary.m \
|
|||
NSDistantObject.m \
|
||||
NSDistributedLock.m \
|
||||
NSDistributedNotificationCenter.m \
|
||||
NSEnergyFormatter.m \
|
||||
NSEnumerator.m \
|
||||
NSError.m \
|
||||
NSException.m \
|
||||
|
@ -244,6 +246,7 @@ NSKeyedArchiver.m \
|
|||
NSKeyedUnarchiver.m \
|
||||
NSKeyValueCoding.m \
|
||||
NSKeyValueObserving.m \
|
||||
NSLengthFormatter.m \
|
||||
NSLocale.m \
|
||||
NSLock.m \
|
||||
NSLog.m \
|
||||
|
@ -405,6 +408,7 @@ NSCompoundPredicate.h \
|
|||
NSConnection.h \
|
||||
NSData.h \
|
||||
NSDateFormatter.h \
|
||||
NSDateInterval.h \
|
||||
NSDate.h \
|
||||
NSDebug.h \
|
||||
NSDecimal.h \
|
||||
|
@ -413,6 +417,7 @@ NSDictionary.h \
|
|||
NSDistantObject.h \
|
||||
NSDistributedLock.h \
|
||||
NSDistributedNotificationCenter.h \
|
||||
NSEnergyFormatter.h \
|
||||
NSEnumerator.h \
|
||||
NSError.h \
|
||||
NSErrorRecoveryAttempting.h \
|
||||
|
@ -439,6 +444,7 @@ NSJSONSerialization.h \
|
|||
NSKeyedArchiver.h \
|
||||
NSKeyValueCoding.h \
|
||||
NSKeyValueObserving.h \
|
||||
NSLengthFormtter.h \
|
||||
NSLocale.h \
|
||||
NSLock.h \
|
||||
NSMapTable.h \
|
||||
|
|
217
Source/NSDateInterval.m
Normal file
217
Source/NSDateInterval.m
Normal file
|
@ -0,0 +1,217 @@
|
|||
|
||||
/* Implementation of class NSDateInterval
|
||||
Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
|
||||
By: Gregory Casamento <greg.casamento@gmail.com>
|
||||
Date: Wed Oct 9 16:24:13 EDT 2019
|
||||
|
||||
This file is part of the GNUstep Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#include <Foundation/NSDateInterval.h>
|
||||
#include <Foundation/NSDate.h>
|
||||
#include <Foundation/NSArray.h>
|
||||
|
||||
@implementation NSDateInterval
|
||||
|
||||
// Init
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if(self != nil)
|
||||
{
|
||||
_startDate = nil;
|
||||
_duration = 0.0;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithStartDate:(NSDate *)startDate
|
||||
duration:(NSTimeInterval)duration
|
||||
{
|
||||
self = [super init];
|
||||
if(self != nil)
|
||||
{
|
||||
ASSIGNCOPY(_startDate, startDate);
|
||||
ASSIGNCOPY(_endDate, [startDate dateByAddingTimeInterval: duration]);
|
||||
_duration = duration;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithStartDate:(NSDate *)startDate
|
||||
endDate:(NSDate *)endDate
|
||||
{
|
||||
self = [super init];
|
||||
if(self != nil)
|
||||
{
|
||||
ASSIGNCOPY(_startDate, startDate);
|
||||
ASSIGNCOPY(_endDate, endDate);
|
||||
_duration = [endDate timeIntervalSinceDate: startDate];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype) initWithCoder: (NSCoder *)coder
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void) encodeWithCoder: (NSCoder *)coder
|
||||
{
|
||||
}
|
||||
|
||||
- (id) copyWithZone: (NSZone *)zone
|
||||
{
|
||||
return [[[self class] allocWithZone: zone]
|
||||
initWithStartDate: _startDate
|
||||
duration: _duration];
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(_startDate);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
// Access
|
||||
- (NSDate *) startDate
|
||||
{
|
||||
return _startDate;
|
||||
}
|
||||
|
||||
- (void) setStartDate: (NSDate *)startDate
|
||||
{
|
||||
ASSIGNCOPY(_startDate, startDate);
|
||||
}
|
||||
|
||||
- (NSDate *) endDate
|
||||
{
|
||||
return _endDate;
|
||||
}
|
||||
|
||||
- (void) setEndDate: (NSDate *)endDate
|
||||
{
|
||||
ASSIGNCOPY(_endDate, endDate);
|
||||
_duration = [endDate timeIntervalSinceDate: _startDate];
|
||||
}
|
||||
|
||||
- (NSTimeInterval) duration
|
||||
{
|
||||
return _duration;
|
||||
}
|
||||
|
||||
- (void) setDuration: (NSTimeInterval)duration
|
||||
{
|
||||
NSDate *newEndDate = [_startDate dateByAddingTimeInterval: duration];
|
||||
_duration = duration;
|
||||
[self setEndDate: newEndDate];
|
||||
}
|
||||
|
||||
// Compare
|
||||
- (NSComparisonResult) compare: (NSDateInterval *)dateInterval
|
||||
{
|
||||
// NSOrderedAscending
|
||||
if([_startDate isEqualToDate: [dateInterval startDate]] &&
|
||||
_duration < [dateInterval duration])
|
||||
return NSOrderedAscending;
|
||||
|
||||
if([_startDate compare: [dateInterval startDate]] == NSOrderedAscending)
|
||||
return NSOrderedAscending;
|
||||
|
||||
// NSOrderedSame
|
||||
if([self isEqualToDateInterval: dateInterval])
|
||||
return NSOrderedSame;
|
||||
|
||||
// NSOrderedDescending
|
||||
if([_startDate isEqualToDate: [dateInterval startDate]] &&
|
||||
_duration > [dateInterval duration])
|
||||
return NSOrderedDescending;
|
||||
|
||||
if([_startDate compare: [dateInterval startDate]] == NSOrderedDescending)
|
||||
return NSOrderedDescending;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (BOOL) isEqualToDateInterval: (NSDateInterval *)dateInterval
|
||||
{
|
||||
return ([_startDate isEqualToDate: [dateInterval startDate]] &&
|
||||
_duration == [dateInterval duration]);
|
||||
}
|
||||
|
||||
// Determine
|
||||
- (BOOL) intersectsDateInterval: (NSDateInterval *)dateInterval
|
||||
{
|
||||
return [self intersectionWithDateInterval: dateInterval] != nil;
|
||||
}
|
||||
|
||||
- (NSDateInterval *) intersectionWithDateInterval: (NSDateInterval *)dateInterval
|
||||
{
|
||||
NSDateInterval *result = nil;
|
||||
NSArray *array = [NSArray arrayWithObjects: self, dateInterval, nil];
|
||||
NSArray *sortedArray = [array sortedArrayUsingSelector: @selector(compare:)];
|
||||
NSDateInterval *first = [sortedArray firstObject];
|
||||
NSDateInterval *last = [sortedArray lastObject];
|
||||
NSDate *intersectStartDate = nil;
|
||||
NSDate *intersectEndDate = nil;
|
||||
|
||||
// Max of start date....
|
||||
if([[first startDate] compare: [last startDate]] == NSOrderedAscending ||
|
||||
[[first startDate] isEqualToDate: [last startDate]])
|
||||
{
|
||||
intersectStartDate = [last startDate];
|
||||
}
|
||||
if([[first startDate] compare: [last startDate]] == NSOrderedDescending)
|
||||
{
|
||||
intersectStartDate = [first startDate];
|
||||
}
|
||||
|
||||
// Min of end date...
|
||||
if([[first endDate] compare: [last endDate]] == NSOrderedDescending ||
|
||||
[[first endDate] isEqualToDate: [last endDate]])
|
||||
{
|
||||
intersectEndDate = [last endDate];
|
||||
}
|
||||
if([[first endDate] compare: [last endDate]] == NSOrderedAscending)
|
||||
{
|
||||
intersectEndDate = [first endDate];
|
||||
}
|
||||
|
||||
if([intersectStartDate compare: intersectEndDate] == NSOrderedAscending)
|
||||
{
|
||||
result = [[NSDateInterval alloc] initWithStartDate: intersectStartDate
|
||||
endDate: intersectEndDate];
|
||||
AUTORELEASE(result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Contain
|
||||
- (BOOL) containsDate: (NSDate *)date
|
||||
{
|
||||
return ([_startDate compare: date] == NSOrderedSame ||
|
||||
[_endDate compare: date] == NSOrderedSame ||
|
||||
([_startDate compare: date] == NSOrderedAscending &&
|
||||
[_endDate compare: date] == NSOrderedDescending));
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
|
31
Source/NSDateIntervalFormatter.m
Normal file
31
Source/NSDateIntervalFormatter.m
Normal file
|
@ -0,0 +1,31 @@
|
|||
|
||||
/* Implementation of class NSDateIntervalFormatter
|
||||
Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
|
||||
By: heron
|
||||
Date: Wed Oct 9 16:23:55 EDT 2019
|
||||
|
||||
This file is part of the GNUstep Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#include <Foundation/NSDateIntervalFormatter.h>
|
||||
|
||||
@implementation NSDateIntervalFormatter
|
||||
|
||||
@end
|
||||
|
31
Source/NSEnergyFormatter.m
Normal file
31
Source/NSEnergyFormatter.m
Normal file
|
@ -0,0 +1,31 @@
|
|||
|
||||
/* Implementation of class NSEnergyFormatter
|
||||
Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
|
||||
By: heron
|
||||
Date: Tue Oct 8 13:30:10 EDT 2019
|
||||
|
||||
This file is part of the GNUstep Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#include <Foundation/NSEnergyFormatter.h>
|
||||
|
||||
@implementation NSEnergyFormatter
|
||||
|
||||
@end
|
||||
|
31
Source/NSLengthFormatter.m
Normal file
31
Source/NSLengthFormatter.m
Normal file
|
@ -0,0 +1,31 @@
|
|||
|
||||
/* Implementation of class NSLengthFormatter
|
||||
Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
|
||||
By: heron
|
||||
Date: Tue Oct 8 13:30:33 EDT 2019
|
||||
|
||||
This file is part of the GNUstep Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#include <Foundation/NSLengthFormatter.h>
|
||||
|
||||
@implementation NSLengthFormatter
|
||||
|
||||
@end
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
/* Implementation of class NSMeasurement
|
||||
Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
|
||||
By: heron
|
||||
By: Gregory John Casamento <greg.casamento@gmail.com>
|
||||
Date: Mon Sep 30 15:58:21 EDT 2019
|
||||
|
||||
This file is part of the GNUstep Library.
|
||||
|
@ -24,8 +24,134 @@
|
|||
*/
|
||||
|
||||
#include <Foundation/NSMeasurement.h>
|
||||
#include <Foundation/NSUnit.h>
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSArchiver.h>
|
||||
#include <Foundation/NSKeyedArchiver.h>
|
||||
|
||||
@implementation NSMeasurement
|
||||
// Creating Measurements
|
||||
- (instancetype)initWithDoubleValue: (double)doubleValue
|
||||
unit: (NSUnit *)unit
|
||||
{
|
||||
self = [super init];
|
||||
if(self != nil)
|
||||
{
|
||||
ASSIGNCOPY(_unit, unit);
|
||||
_doubleValue = doubleValue;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(_unit);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
// Accessing unit and value
|
||||
- (NSUnit *) unit
|
||||
{
|
||||
return _unit;
|
||||
}
|
||||
|
||||
- (double) doubleValue
|
||||
{
|
||||
return _doubleValue;
|
||||
}
|
||||
|
||||
// Conversion
|
||||
- (BOOL) canBeConvertedToUnit: (NSUnit *)unit
|
||||
{
|
||||
return ([unit isKindOfClass: [_unit class]] &&
|
||||
[unit respondsToSelector: @selector(converter)]);
|
||||
}
|
||||
|
||||
- (NSMeasurement *)measurementByConvertingToUnit:(NSUnit *)unit
|
||||
{
|
||||
NSMeasurement *result = nil;
|
||||
double val = 0.0;
|
||||
if([self canBeConvertedToUnit: unit])
|
||||
{
|
||||
// Do conversion...
|
||||
NSUnitConverter *c = [(NSDimension *)unit converter];
|
||||
val = [c baseUnitValueFromValue: _doubleValue];
|
||||
result = [[NSMeasurement alloc] initWithDoubleValue: val unit: unit];
|
||||
AUTORELEASE(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Cannot convert from %@ to %@", _unit, unit];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Operating
|
||||
- (NSMeasurement *)measurementByAddingMeasurement:(NSMeasurement *)measurement
|
||||
{
|
||||
NSMeasurement *newMeasurement = [measurement measurementByConvertingToUnit: _unit];
|
||||
NSMeasurement *result = nil;
|
||||
double v = 0.0;
|
||||
|
||||
v = _doubleValue + [newMeasurement doubleValue];
|
||||
result = [[NSMeasurement alloc] initWithDoubleValue: v unit: _unit];
|
||||
AUTORELEASE(result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
- (NSMeasurement *)measurementBySubtractingMeasurement:(NSMeasurement *)measurement
|
||||
{
|
||||
NSMeasurement *newMeasurement = [measurement measurementByConvertingToUnit: _unit];
|
||||
NSMeasurement *result = nil;
|
||||
double v = 0.0;
|
||||
|
||||
v = _doubleValue - [newMeasurement doubleValue];
|
||||
result = [[NSMeasurement alloc] initWithDoubleValue: v unit: _unit];
|
||||
AUTORELEASE(result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// NSCopying
|
||||
- (id) copyWithZone: (NSZone *)zone
|
||||
{
|
||||
return [[[self class] allocWithZone: zone] initWithDoubleValue: _doubleValue
|
||||
unit: _unit];
|
||||
}
|
||||
|
||||
// NSCoding
|
||||
- (void) encodeWithCoder: (NSCoder *)coder
|
||||
{
|
||||
if([coder allowsKeyedCoding])
|
||||
{
|
||||
[coder encodeObject: _unit forKey: @"unit"];
|
||||
[coder encodeDouble: _doubleValue forKey: @"doubleValue"];
|
||||
}
|
||||
else
|
||||
{
|
||||
[coder encodeObject: _unit];
|
||||
[coder encodeValueOfObjCType: @encode(double) at: &_doubleValue];
|
||||
}
|
||||
}
|
||||
|
||||
- (id) initWithCoder: (NSCoder *)coder
|
||||
{
|
||||
if((self = [super init]) != nil)
|
||||
{
|
||||
if([coder allowsKeyedCoding])
|
||||
{
|
||||
_unit = [coder decodeObjectForKey: @"unit"];
|
||||
_doubleValue = [coder decodeDoubleForKey: @"doubleValue"];
|
||||
}
|
||||
else
|
||||
{
|
||||
_unit = [coder decodeObject];
|
||||
[coder decodeValueOfObjCType: @encode(double) at: &_doubleValue];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@end
|
||||
|
||||
|
|
|
@ -24,8 +24,63 @@
|
|||
*/
|
||||
|
||||
#include <Foundation/NSMeasurementFormatter.h>
|
||||
#include <Foundation/NSLocale.h>
|
||||
#include <Foundation/NSMeasurement.h>
|
||||
#include <Foundation/NSNumberFormatter.h>
|
||||
#include <Foundation/NSUnit.h>
|
||||
|
||||
@implementation NSMeasurementFormatter
|
||||
|
||||
- (NSMeasurementFormatterUnitOptions) unitOptions
|
||||
{
|
||||
return _unitOptions;
|
||||
}
|
||||
|
||||
- (void) setUnitOptions: (NSMeasurementFormatterUnitOptions) unitOptions
|
||||
{
|
||||
_unitOptions = unitOptions;
|
||||
}
|
||||
|
||||
- (NSFormattingUnitStyle) unitStyle
|
||||
{
|
||||
return _unitStyle;
|
||||
}
|
||||
|
||||
- (void) setUnitStyle: (NSFormattingUnitStyle)style
|
||||
{
|
||||
_unitStyle = style;
|
||||
}
|
||||
|
||||
- (NSLocale *) locale
|
||||
{
|
||||
return _locale;
|
||||
}
|
||||
|
||||
- (void) setLocale: (NSLocale *)locale
|
||||
{
|
||||
ASSIGNCOPY(_locale, locale);
|
||||
}
|
||||
|
||||
- (NSNumberFormatter *) numberFormatter
|
||||
{
|
||||
return _numberFormatter;
|
||||
}
|
||||
|
||||
- (void) setNumberFormatter: (NSNumberFormatter *)numberFormatter
|
||||
{
|
||||
ASSIGNCOPY(_numberFormatter, numberFormatter);
|
||||
}
|
||||
|
||||
- (NSString *)stringFromMeasurement: (NSMeasurement *)measurement
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSString *)stringFromUnit: (NSUnit *)unit
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
|
1699
Source/NSUnit.m
1699
Source/NSUnit.m
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue