home *** CD-ROM | disk | FTP | other *** search
/ Super Net 1 / SUPERNET_1.iso / PC / OTROS / UNIX / ARCHIE / CLIENTS / NEXTARCH / DATE.H < prev    next >
Encoding:
Text File  |  1992-01-16  |  2.8 KB  |  84 lines

  1. /* A date class based on the routines in COMPUTER LANGAUGE V7, No12, 1990
  2.     page 57-62 */
  3.  
  4. #import <objc/Object.h>
  5.  
  6. typedef long JulianDate;
  7. typedef short WeekDay;
  8. typedef short Day;
  9. typedef short Month;
  10. typedef short Year;
  11.  
  12. @interface Date : Object
  13. {
  14.     char *dateString;        // A date string in the form day/month/year
  15.     JulianDate date;        // The Julian day number
  16.     // The corresponding integer values
  17.     Day day;
  18.     Month month;
  19.     Year year;
  20.     // The 24 hour time
  21.     short hours;
  22.     short minutes;
  23.     short seconds;
  24.     char errorMode;        // The error mode flag
  25. }
  26.  
  27. /* Actions */
  28.  
  29. /* Class methods */
  30. + (const char *) selName : (SEL) theSEL;
  31.  
  32. /* initialization methods */
  33. - initFromString : (char *) theDate;
  34. - initFromDate : (Day) d : (Month) m : (Year) y;
  35. - initFromJulianDate : (JulianDate) jDate;
  36. - initFromNow;
  37. - setTime : (short) hr : (short) min : (short) sec;
  38. - free;
  39.  
  40. /* Set whether an invalid date will either
  41.     1) Simply return a nil object: mode = 0 (this is the default)
  42.     2) Display an alert panel and then return nil: mode = 1
  43.     3) Display an alert panel and allow the user to correct the date: mode = 2
  44. */
  45. - setErrorMode : (int) mode;
  46.  
  47. /* Conversion functions */
  48. // Returns the calendar date of jDate
  49. - calendarDate : (JulianDate) jDate : (Day *) d : (Month *) m : (Year *) y;
  50. - (JulianDate) julianRep : (Day) d : (Month) m : (Year) y;  // Returns the Julian rep for the calendar date
  51. - (JulianDate) julianDate;        // Returns the date in its Julian representation
  52. - (WeekDay) weekDay;        // Returns the day of the week [0-6]
  53. - (Day) day;                    // Returns the day of the month
  54. - (Month) month;                // Returns the month [0-11]
  55. - (Year) year;                // Returns the year
  56. - (short) hours;                // Returns the hours
  57. - (short) minutes;                // Returns the minutes
  58. - (short) seconds;            // Returns the seconds
  59. - (void) time : (short *) hr : (short *) min : (short *) sec;  // Set to the objects time
  60. - (const char *) stringDate;        // Returns the date in the form "m/d/yyyy"
  61. - (const char *) stringFixedDate;    // Returns the date in the form "mm/dd/yyyy"
  62. - (const char *) fullStringDate;        // Returns the date in the form "DayOfWeek Month dd Year"
  63. - (const char *) time24hr;            // Returns the time string "hh:mm"
  64. - (const char *) timeAM_PM;        // Returns the time string "h[h]:mm [AP]m" where h <= 12
  65.  
  66. /* System time access */
  67. // Set the componets to those returned by localtime(3)
  68. - (void) now : (Day *) d : (Month *) m : (Year *) y : (short *) hr : (short *) min : (short *) sec;
  69. // Return the system clock time(3)
  70. - (long) sysTime;
  71.  
  72. /* Ouput */
  73. - (void) print;
  74.  
  75. /* Private methods to check the date and report errors */
  76. - (BOOL) validDate;
  77. - invalidDate : (SEL) callingMethod;
  78. /* Method invoked by the Ok button of the editErrorPanel */
  79. - dateOk : sender;
  80. /* Method invoked by the ``Return nil'' button of the editErrorPanel */
  81. - dateCancel : sender;
  82.  
  83. @end
  84.