home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / pascal / shdk_1.zip / TESTDATE.PAS < prev    next >
Pascal/Delphi Source File  |  1992-03-23  |  3KB  |  86 lines

  1. program TestDate;
  2. {
  3.                         To test the ShDatPk unit
  4.  
  5.                   Copyright 1991 Madison & Associates
  6.                           All Rights Reserved
  7.  
  8.          This program source file and the associated executable
  9.          file may be  used and distributed  only in  accordance
  10.          with the  provisions  described  on  the title page of
  11.                   the accompanying documentation file
  12.                               SKYHAWK.DOC
  13. }
  14.  
  15. uses
  16.   ShDatPk;
  17.  
  18. var
  19.   G               : GregType;
  20.   T               : TimeType;
  21.   Year,
  22.   Month,
  23.   Day,
  24.   Weekday,
  25.   JulianDate      : array[1..3] of integer;
  26.   JulianDayNumber : array[1..2] of LongInt;
  27.   Greg            : array[1..3] of GregType;
  28.  
  29. begin
  30.   JDN2Greg(Today, G);
  31.   WriteLn('Today is day number ',Today,', a ',DayStr[DoW(G)]);
  32.   WriteLn('Today''s date (TodayStr) is ',TodayStr('='));
  33.   WriteLn('Today''s date (JDN2Str) is ',JDN2Str(Today,'/'));
  34.   WriteLn('   as an ANSI string (YYYYMMDD) ', Today2ANSI);
  35.   WriteLn;
  36.   WriteLn('The time in seconds since midnight is ',Now);
  37.   WriteLn('    the a.m./p.m. time is ',NowStr(':',false));
  38.   WriteLn('    the undelimited time is ',NowStr('',false));
  39.   WriteLn;
  40.   WriteLn('    the military time is ',NowStr('',true));
  41.   WriteLn('    the 24-hour time is ',NowStr(':',true));
  42.   SSM2Time(Now, T);
  43.   WriteLn('    the 24-hour time (SSM2Time, Time2TimeStr) is ',
  44.                                                   Time2TimeStr(T,':',true));
  45.   Now2Time(T);
  46.   WriteLn('    the 24-hour time (Now2Time, Time2TimeStr) is ',
  47.                                                   Time2TimeStr(T,':',true));
  48.   WriteLn('    the 24-hour time (Time2SSM, SSM2TimeStr) is ',
  49.                                        SSM2TimeStr(Time2SSM(T), '.', true));
  50.   WriteLn;
  51.   WriteLn('The remainder of this testing program will allow you to');
  52.   WriteLn('  experiment with dates of your own choosing, entered as');
  53.   WriteLn('  year, month, day in response to the prompts. ');
  54.   WriteLn;
  55.   WriteLn(^G'  Note that the YEAR does not default to the 20th century.');
  56.   WriteLn('<Ctrl-Break> out of this program.');
  57.   WriteLn;
  58.   repeat
  59.     Write('Year   » '); ReadLn(Greg[1].Year);
  60.     Write('Month  » '); ReadLn(Greg[1].Month);
  61.     Write('Day    » '); ReadLn(Greg[1].Day); WriteLn;
  62.  
  63.     WriteLn('You entered:');
  64.     WriteLn('     ',DayStr[DoW(Greg[1])],', ',MonthStr[Greg[1].Month],
  65.                     ' ',Greg[1].Day,', ',Greg[1].Year);
  66.     WriteLn;
  67.  
  68.     JulianDayNumber[1] := Greg2JDN(Greg[1]);
  69.     JDN2Greg(JulianDayNumber[1], Greg[2]);
  70.     JulianDate[1] := Greg2JDate(Greg[2]);
  71.     Greg[3].Year := Greg[1].Year;
  72.     JDate2Greg(JulianDate[1], Greg[3].Year, Greg[3]);
  73.     Weekday[1] := DoW(Greg[3]);
  74.  
  75.     with Greg[1] do
  76.       WriteLn(Month,'/',Day,'/',Year,' is day number ',
  77.               JulianDayNumber[1]);
  78.     with Greg[2] do
  79.       WriteLn(Month,'/',Day,'/',Year,' is day ',
  80.               JulianDate[1],' of the year.');
  81.     with Greg[3] do
  82.       WriteLn(MonthStr[Month],' ',Day,', ',Year,' is a ',DayStr[Weekday[1]]);
  83.     WriteLn; WriteLn;
  84.     until false;
  85.     end.
  86.