-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDateTime.pas
More file actions
100 lines (81 loc) · 2.56 KB
/
DateTime.pas
File metadata and controls
100 lines (81 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
{*************************************************************************}
{ This file is part of Files And Folders. }
{ Copyright (c) 1997-2025 Hellogramming }
{ https://www.hellogramming.com/ }
{ }
{ Files And Folders is free software; you can redistribute it and/or }
{ modify it under the terms of the MIT License. }
{*************************************************************************}
unit DateTime;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Grids, Calendar, StdCtrls, ComCtrls, Mask;
var
FDateTime : TFileTime;
DateTimeChanged : Boolean;
type
TDateTimeBox = class(TForm)
cmdChange: TButton;
cmdCancel: TButton;
TheDate: TDateTimePicker;
Label1: TLabel;
Label2: TLabel;
ediTime: TEdit;
cmdNow: TButton;
procedure cmdChangeClick(Sender: TObject);
procedure cmdCancelClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure cmdNowClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
DateTimeBox: TDateTimeBox;
implementation
{$R *.DFM}
procedure TDateTimeBox.cmdChangeClick(Sender: TObject);
var
STime : TSystemTime;
LocalFileTime : TFileTime;
T : TDateTime;
begin
T := StrToTime(ediTime.Text); { convert time from time field }
{ calc new date/time }
DateTimeToSystemTime(Int(TheDate.Date) + Frac(T), STime);
SystemTimeToFileTime(STime, LocalFileTime);
LocalFileTimeToFileTime(LocalFileTime, FDateTime);
DateTimeChanged := True;
Close; { close form }
end;
procedure TDateTimeBox.cmdCancelClick(Sender: TObject);
begin
Close;
end;
procedure TDateTimeBox.FormCreate(Sender: TObject);
var
LocalFileTime : TFileTime;
STime : TSystemTime;
DT : TDateTime;
begin
DateTimeChanged := False;
cmdNow.Height := ediTime.Height + 1;
FileTimeToLocalFileTime(FDateTime, LocalFileTime);
FileTimeToSystemTime(LocalFileTime, STime);
DT := SystemTimeToDateTime(STime);
TheDate.ShowCheckBox := (Int(DT) = 0);
TheDate.Date := DT;
ediTime.Text := TimeToStr(Frac(DT));
if TheDate.Checked = False then
begin
TheDate.Date := Now;
TheDate.Checked := False;
end;
end;
procedure TDateTimeBox.cmdNowClick(Sender: TObject);
begin
ediTime.Text := TimeToStr(Now);
end;
end.