home *** CD-ROM | disk | FTP | other *** search
- //
- // MiscTime.h -- a generic class to simplify manipulation of times
- // Written by Don Yacktman Copyright (c) 1993 by Don Yacktman.
- // Version 1.0. All rights reserved.
- // This notice may not be removed from this source code.
- //
- // This object is included in the MiscKit by permission from the author
- // and its use is governed by the MiscKit license, found in the file
- // "LICENSE.rtf" in the MiscKit distribution. Please refer to that file
- // for a list of all applicable permissions and restrictions.
- //
-
- #import <appkit/appkit.h>
-
- #define MISC_TIME_UNKNOWN_DOW -1 // for uncalced day of week
- #define MISC_TIME_MAX_MICROSECONDS 1000000
- #define MISC_TIME_MAX_SECONDS 60
- #define MISC_TIME_MAX_MINUTES 60
- #define MISC_TIME_MAX_HOURS 24
- #define MISC_TIME_MAX_DAYS 365
- #define MISC_TIME_MAX_MONTHS 12
-
- @interface MiscTime:Object <NXTransport>
- {
- BOOL isRelative; // if we are absolute date or a relative measure.
- long microsecond, second, minute, hour, dow, day, month, year;
- char *myStringValue;
- @private BOOL _initted;
- }
-
- - init;
- - initWithCurrentTime;
-
- - setYear:(int)t;
- - setMonth:(int)t;
- - setDayOfWeek:(int)t;
- - calcDayOfWeek; // set the year, month, and day first.
- - setDay:(int)t;
- - setHour:(int)t;
- - setMinute:(int)t;
- - setSecond:(int)t;
- - setMicrosecond:(int)t;
- - setRelative:(BOOL)t;
- - (BOOL)isRelative;
-
- - (int)_nintValue; // private method, does intValue w/o usecs.
- - (int)intValue;
- - (float)floatValue;
- - (double)doubleValue;
- - (const char *)stringValue;
-
- - (int)year;
- - (int)month;
- - (int)dayOfWeek;
- - (int)day;
- - (int)hour;
- - (int)minute;
- - (int)second;
- - (int)microsecond;
-
- - addTime:aTime;
- - subtractTime:aTime;
-
- - addMicroseconds:(long)t;
- - addSeconds:(long)t;
- - addMinutes:(long)t;
- - addHours:(long)t;
- - addDays:(long)t;
- - addWeeks:(long)t;
- - addMonths:(long)t;
- - addYears:(long)t;
-
- - subtractMicroseconds:(long)t;
- - subtractSeconds:(long)t;
- - subtractMinutes:(long)t;
- - subtractHours:(long)t;
- - subtractDays:(long)t;
- - subtractWeeks:(long)t;
- - subtractMonths:(long)t;
- - subtractYears:(long)t;
-
- - (BOOL)isAfter:aTime;
- - (BOOL)isEqual:aTime;
-
- - copy;
- - copyTimeFrom:aTime;
- - read:(NXTypedStream *)stream;
- - write:(NXTypedStream *)stream;
-
- @end
-