home *** CD-ROM | disk | FTP | other *** search
/ PC Format Collection 48 / SENT14D.ISO / tech / delphi / disk15 / format.pak / DATES.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-08-24  |  1.1 KB  |  51 lines

  1. unit Dates;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, StdCtrls;
  8.  
  9. type
  10.   TDateForm = class(TForm)
  11.     ValueEdit: TComboBox;
  12.     FormatEdit: TComboBox;
  13.     ResultEdit: TEdit;
  14.     Label1: TLabel;
  15.     Label2: TLabel;
  16.     Label3: TLabel;
  17.     Button1: TButton;
  18.     procedure Button1Click(Sender: TObject);
  19.     procedure FormCreate(Sender: TObject);
  20.   private
  21.     { Private declarations }
  22.   public
  23.     { Public declarations }
  24.   end;
  25.  
  26. var
  27.   DateForm: TDateForm;
  28.  
  29. implementation
  30.  
  31. {$R *.DFM}
  32.  
  33. procedure TDateForm.Button1Click(Sender: TObject);
  34. begin
  35.   ResultEdit.Text := FormatDateTime(FormatEdit.Text, StrToDateTime(ValueEdit.Text));
  36. end;
  37.  
  38. procedure TDateForm.FormCreate(Sender: TObject);
  39. begin
  40.   with ValueEdit.Items do
  41.   begin
  42.     Add(DateToStr(EncodeDate(1995,1,1)) + ' 9' + TimeSeparator + '30');
  43.     Add(DateToStr(EncodeDate(1999,12,31)) + ' 23' + TimeSeparator + '59' +
  44.       TimeSeparator + '59');
  45.     Add(DateToStr(EncodeDate(1998,1,1)));
  46.   end;
  47.   ValueEdit.Text := DateTimeToStr(Now);
  48. end;
  49.  
  50. end.
  51.