home *** CD-ROM | disk | FTP | other *** search
/ Carousel Volume 2 #1 / carousel.iso / mactosh / hc / turbopgl.sit / Mildate.p < prev    next >
Encoding:
Text File  |  1988-03-04  |  2.7 KB  |  96 lines  |  [TEXT/TPAS]

  1. program MilDate;
  2.  
  3. {
  4.    Written by: Stephen Kurtzman
  5.     Very slightly modified by Brian Liebowitz...Steve got it right for the 
  6.       DHDR's that he was using, so if it doesn't work it's my fault.
  7.  
  8.    Public distribution is neither prohibited nor discouraged. Hell, you
  9.    don't even have to keep our names on it.
  10.    
  11.    This function returns the military date format for the integer 
  12. time/date
  13.    specification passed. the integer is encoded as number of seconds since
  14.    midnight, 01-Jan-1904. For more information on the system routines 
  15. used
  16.    in this procedure, see page 380 of Inside Macintosh, V II.
  17.  
  18.     You must install the DHDR resources called PasXFCN and PasXCMD 
  19.     into your copy of Turbo before compiling this XCMD.  You must also 
  20.      have compiled the unit HyperXCMD and moved it into the Turbo progam,
  21.       and the file XCMDGlue.inc must be accessible.  After compiling,use
  22.      ResEdit to change the ID from 300, and to copy the XCMD or XFCN into 
  23.     your stack or Hypercard.
  24. }
  25.  
  26. {$R-}       { turn off index checking }
  27. {$U-}       { don't let Turbo give us units by default }
  28. {$D PasXFCN}   { tell Turbo to create an XFCN resource }
  29.  
  30. USES Memtypes, Quickdraw, OSIntf, HyperXCmd;
  31.  
  32. PROCEDURE PasXFCN(paramPtr: XCmdPtr);
  33.  
  34. VAR
  35.     seconds, tempint: longint;
  36.     str: Str255;
  37.     date: DateTimeRec;
  38.     monstr: string[3];
  39.  
  40. {$I Xcmdglue.inc}  {include the Pascal glue procedures}
  41.  
  42. BEGIN
  43.   
  44.     { the first parameter is the date/time integer specification }
  45.     
  46.     ZeroToPas(paramPtr^.params[1]^,str);
  47.     seconds := StrToNum(str);
  48.     
  49.     { if the specification is zero, then get the current }
  50.     
  51.     if seconds = 0 then GetDateTime(seconds);
  52.     
  53.     { convert the date specification to a date/time record }
  54.     
  55.     Secs2Date(seconds,date);
  56.     
  57.     { convert integer to long integer }
  58.     
  59.     tempint := Ord4(date.day);
  60.     
  61.     { encode the day of the month as a two character string }
  62.     
  63.     str := Concat(LongToStr(tempint div 10),LongToStr(tempint mod 10));
  64.  
  65.     { select the proper three character month string }
  66.                       
  67.     case date.month of
  68.         1: monstr := 'Jan';
  69.         2: monstr := 'Feb';
  70.         3: monstr := 'Mar';
  71.         4: monstr := 'Apr';
  72.         5: monstr := 'May';
  73.         6: monstr := 'Jun';
  74.         7: monstr := 'Jul';
  75.         8: monstr := 'Aug';
  76.         9: monstr := 'Sep';
  77.        10: monstr := 'Oct';
  78.        11: monstr := 'Nov';
  79.        12: monstr := 'Dec'
  80.     end;
  81.     
  82.     { put it all together and return the string to hypercard }
  83.     
  84.     paramPtr^.returnValue := PasToZero(Concat(str,'-',monstr,'-',
  85.                                                LongToStr(Ord4(date.year))))
  86.           
  87. END;
  88.  
  89. BEGIN
  90. END.
  91.  
  92. (*Remember to change the ID of this resource from 300*)
  93.  
  94.  
  95.  
  96.