Check-in [99b04e4d68]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Calculate totals when adjusting times. Check for date change on update; fetch new times when that happens. New executable included.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 99b04e4d688eb3a0fe29568cf87fdbf5a508cc6c
User & Date: tinus 2014-12-04 09:39:38
Context
2015-05-08
08:52
Bugfixes in handling lunch times. Leaf check-in: 63ccfa869a user: tinus tags: trunk
2014-12-04
09:39
Calculate totals when adjusting times. Check for date change on update; fetch new times when that happens. New executable included. check-in: 99b04e4d68 user: tinus tags: trunk
09:04
Added feature to manually adjust work and lunch times. check-in: c2c21599e3 user: tinus tags: trunk
Changes

Changes to out/TempusFugit.exe.

cannot compute difference between binary files

Changes to src/F_Main.dfm.

121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
      OnClick = miCloseClick
    end
  end
  object imlMain: TImageList
    Left = 32
    Top = 232
    Bitmap = {
      494C010102000400280010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
      0000000000003600000028000000400000001000000001002000000000000010
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000







|







121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
      OnClick = miCloseClick
    end
  end
  object imlMain: TImageList
    Left = 32
    Top = 232
    Bitmap = {
      494C0101020004002C0010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
      0000000000003600000028000000400000001000000001002000000000000010
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000

Changes to src/F_Main.pas.

536
537
538
539
540
541
542



543

544

545
546
547
548
549
550
551
  end;
end{TfrmMain.tmrFetchTimesTimer};

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmMain.tmrUpdateProgressTimer(Sender: TObject);
begin
  try



    FormResize(Self);

    Self.Invalidate;

  except
    on E: Exception do begin
      trayIcon.BalloonHint := E.Message + #13#10'[' + E.ClassName + ']';
      trayIcon.Hint := Application.Title + ' - ' + E.Message;
      trayIcon.Visible := True;
      trayIcon.ShowBalloonHint;
    end;







>
>
>
|
>
|
>







536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
  end;
end{TfrmMain.tmrFetchTimesTimer};

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmMain.tmrUpdateProgressTimer(Sender: TObject);
begin
  try
    try
      if DateOf(FStopTime) < Date then
        FetchHoursOnline;
      FormResize(Self);
    finally
      Self.Invalidate;
    end;
  except
    on E: Exception do begin
      trayIcon.BalloonHint := E.Message + #13#10'[' + E.ClassName + ']';
      trayIcon.Hint := Application.Title + ' - ' + E.Message;
      trayIcon.Visible := True;
      trayIcon.ShowBalloonHint;
    end;

Changes to src/F_Times.dfm.

25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
..
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
101
102
103
104
105
106
107
108
109
110
111
112
...
119
120
121
122
123
124
125








126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
    Top = 3
    Width = 333
    Height = 107
    Align = alTop
    BevelInner = bvRaised
    BevelOuter = bvLowered
    TabOrder = 0
    ExplicitTop = 44
    ExplicitWidth = 412
    DesignSize = (
      333
      107)
    object lblStart: TLabel
      Left = 8
      Top = 44
      Width = 53
................................................................................
      Left = 8
      Top = 71
      Width = 51
      Height = 13
      Caption = 'Stop &Time:'
      Enabled = False
      FocusControl = dtpStop








    end
    object dtpStart: TDateTimePicker
      Left = 96
      Top = 40
      Width = 89
      Height = 21
      Date = 41977.333333333340000000
      Format = 'HH:mm'
      Time = 41977.333333333340000000
      Enabled = False
      Kind = dtkTime
      ParseInput = True
      TabOrder = 0
      OnChange = dtpTimeChange
    end
    object dtpStop: TDateTimePicker
      Left = 96
      Top = 67
      Width = 89
      Height = 21
      Date = 41977.708333333340000000
      Format = 'HH:mm'
      Time = 41977.708333333340000000
      Enabled = False
      Kind = dtkTime
      ParseInput = True
      TabOrder = 1
      OnChange = dtpTimeChange
    end
    object chkAdjustTimes: TCheckBox
      Left = 8
      Top = 8
      Width = 320
      Height = 17
      Anchors = [akLeft, akTop, akRight]
      Caption = 'Adjust &work times'
      TabOrder = 2
      OnClick = chkAdjustTimesClick
    end
  end
  object pnlLunch: TPanel
    AlignWithMargins = True
    Left = 3
    Top = 116
    Width = 333
    Height = 101
    Align = alTop
    BevelInner = bvRaised
    BevelOuter = bvLowered
    TabOrder = 1
    ExplicitTop = 148
    ExplicitWidth = 412
    DesignSize = (
      333
      101)
    object lblLunchStart: TLabel
      Left = 8
      Top = 44
      Width = 53
................................................................................
      Left = 8
      Top = 71
      Width = 51
      Height = 13
      Caption = 'St&op Time:'
      Enabled = False
      FocusControl = dtpLunchStop








    end
    object dtpLunchStart: TDateTimePicker
      Left = 96
      Top = 40
      Width = 89
      Height = 21
      Date = 41977.500000000000000000
      Format = 'HH:mm'
      Time = 41977.500000000000000000
      Enabled = False
      Kind = dtkTime
      ParseInput = True
      TabOrder = 0
      OnChange = dtpTimeChange
    end
    object dtpLunchStop: TDateTimePicker
      Left = 96
      Top = 67
      Width = 89
      Height = 21
      Date = 41977.520833333340000000
      Format = 'HH:mm'
      Time = 41977.520833333340000000
      Enabled = False
      Kind = dtkTime
      ParseInput = True
      TabOrder = 1
      OnChange = dtpTimeChange
    end
    object chkAdjustLunch: TCheckBox
      Left = 8
      Top = 8
      Width = 320
      Height = 17
      Anchors = [akLeft, akTop, akRight]
      Caption = 'Adjust &lunch times'
      TabOrder = 2
      OnClick = chkAdjustLunchClick
    end
  end
  object btnClose: TButton
    Left = 241
    Top = 234
    Width = 90
    Height = 25
    Anchors = [akRight, akBottom]
    Caption = '&Close'
    Default = True
    TabOrder = 2
    OnClick = btnCloseClick
    ExplicitLeft = 320
    ExplicitTop = 224
  end
  object tmrAutosave: TTimer
    Enabled = False
    OnTimer = tmrAutosaveTimer
    Left = 288
    Top = 16
  end
end







<
<







 







>
>
>
>
>
>
>
>












|













|









|













<
<







 







>
>
>
>
>
>
>
>












|













|









|













<
<








25
26
27
28
29
30
31


32
33
34
35
36
37
38
..
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
101
102
103
104
105
106
107
108
109


110
111
112
113
114
115
116
...
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187


188
189
190
191
192
193
194
195
    Top = 3
    Width = 333
    Height = 107
    Align = alTop
    BevelInner = bvRaised
    BevelOuter = bvLowered
    TabOrder = 0


    DesignSize = (
      333
      107)
    object lblStart: TLabel
      Left = 8
      Top = 44
      Width = 53
................................................................................
      Left = 8
      Top = 71
      Width = 51
      Height = 13
      Caption = 'Stop &Time:'
      Enabled = False
      FocusControl = dtpStop
    end
    object lblTimeWorked: TLabel
      Left = 208
      Top = 71
      Width = 53
      Height = 13
      Caption = '00:00 total'
      ShowAccelChar = False
    end
    object dtpStart: TDateTimePicker
      Left = 96
      Top = 40
      Width = 89
      Height = 21
      Date = 41977.333333333340000000
      Format = 'HH:mm'
      Time = 41977.333333333340000000
      Enabled = False
      Kind = dtkTime
      ParseInput = True
      TabOrder = 1
      OnChange = dtpTimeChange
    end
    object dtpStop: TDateTimePicker
      Left = 96
      Top = 67
      Width = 89
      Height = 21
      Date = 41977.708333333340000000
      Format = 'HH:mm'
      Time = 41977.708333333340000000
      Enabled = False
      Kind = dtkTime
      ParseInput = True
      TabOrder = 2
      OnChange = dtpTimeChange
    end
    object chkAdjustTimes: TCheckBox
      Left = 8
      Top = 8
      Width = 320
      Height = 17
      Anchors = [akLeft, akTop, akRight]
      Caption = 'Adjust &work times'
      TabOrder = 0
      OnClick = chkAdjustTimesClick
    end
  end
  object pnlLunch: TPanel
    AlignWithMargins = True
    Left = 3
    Top = 116
    Width = 333
    Height = 101
    Align = alTop
    BevelInner = bvRaised
    BevelOuter = bvLowered
    TabOrder = 1


    DesignSize = (
      333
      101)
    object lblLunchStart: TLabel
      Left = 8
      Top = 44
      Width = 53
................................................................................
      Left = 8
      Top = 71
      Width = 51
      Height = 13
      Caption = 'St&op Time:'
      Enabled = False
      FocusControl = dtpLunchStop
    end
    object lblTimeLunched: TLabel
      Left = 208
      Top = 71
      Width = 53
      Height = 13
      Caption = '00:00 total'
      ShowAccelChar = False
    end
    object dtpLunchStart: TDateTimePicker
      Left = 96
      Top = 40
      Width = 89
      Height = 21
      Date = 41977.500000000000000000
      Format = 'HH:mm'
      Time = 41977.500000000000000000
      Enabled = False
      Kind = dtkTime
      ParseInput = True
      TabOrder = 1
      OnChange = dtpTimeChange
    end
    object dtpLunchStop: TDateTimePicker
      Left = 96
      Top = 67
      Width = 89
      Height = 21
      Date = 41977.520833333340000000
      Format = 'HH:mm'
      Time = 41977.520833333340000000
      Enabled = False
      Kind = dtkTime
      ParseInput = True
      TabOrder = 2
      OnChange = dtpTimeChange
    end
    object chkAdjustLunch: TCheckBox
      Left = 8
      Top = 8
      Width = 320
      Height = 17
      Anchors = [akLeft, akTop, akRight]
      Caption = 'Adjust &lunch times'
      TabOrder = 0
      OnClick = chkAdjustLunchClick
    end
  end
  object btnClose: TButton
    Left = 241
    Top = 234
    Width = 90
    Height = 25
    Anchors = [akRight, akBottom]
    Caption = '&Close'
    Default = True
    TabOrder = 2
    OnClick = btnCloseClick


  end
  object tmrAutosave: TTimer
    Enabled = False
    OnTimer = tmrAutosaveTimer
    Left = 288
    Top = 16
  end
end

Changes to src/F_Times.pas.

18
19
20
21
22
23
24


25
26
27
28
29
30
31
32
33
34

35
36
37
38
39
40
41
..
51
52
53
54
55
56
57

58
59
60
61
62
63
64

65
66
67
68
69
70
71
..
81
82
83
84
85
86
87





















88
89
90
91
92
93
94
    lblLunchStop: TLabel;
    dtpLunchStart: TDateTimePicker;
    dtpLunchStop: TDateTimePicker;
    chkAdjustTimes: TCheckBox;
    chkAdjustLunch: TCheckBox;
    btnClose: TButton;
    tmrAutosave: TTimer;


    procedure chkAdjustTimesClick(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure chkAdjustLunchClick(Sender: TObject);
    procedure tmrAutosaveTimer(Sender: TObject);
    procedure dtpTimeChange(Sender: TObject);
    procedure btnCloseClick(Sender: TObject);
  private
    { Private declarations }
    procedure EnableControls;
    procedure StartTimer;

  public
    { Public declarations }
  end;

var
  frmEditTimes: TfrmEditTimes;

................................................................................
begin
  dtpStart.Time := frmMain.StartTime;
  dtpStop.Time := frmMain.StopTime;
  chkAdjustTimes.Checked := frmMain.UserTimes;
  dtpLunchStart.Time := frmMain.StartLunch;
  dtpLunchStop.Time := frmMain.StopLunch;
  chkAdjustLunch.Checked := frmMain.UserLunch;

end;

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmEditTimes.StartTimer;
begin
  tmrAutosave.Enabled := False;
  tmrAutosave.Enabled := True;

end;

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmEditTimes.tmrAutosaveTimer(Sender: TObject);
begin
  tmrAutosave.Enabled := False;
  frmMain.UserTimes := chkAdjustTimes.Checked;
................................................................................
end;

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmEditTimes.btnCloseClick(Sender: TObject);
begin
  Self.Hide;
end;






















{ ------------------------------------------------------------------------------------------------ }
procedure TfrmEditTimes.chkAdjustLunchClick(Sender: TObject);
begin
  EnableControls;
  StartTimer;
  frmMain.UserLunch := chkAdjustLunch.Checked;







>
>










>







 







>







>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
..
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
..
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
    lblLunchStop: TLabel;
    dtpLunchStart: TDateTimePicker;
    dtpLunchStop: TDateTimePicker;
    chkAdjustTimes: TCheckBox;
    chkAdjustLunch: TCheckBox;
    btnClose: TButton;
    tmrAutosave: TTimer;
    lblTimeWorked: TLabel;
    lblTimeLunched: TLabel;
    procedure chkAdjustTimesClick(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure chkAdjustLunchClick(Sender: TObject);
    procedure tmrAutosaveTimer(Sender: TObject);
    procedure dtpTimeChange(Sender: TObject);
    procedure btnCloseClick(Sender: TObject);
  private
    { Private declarations }
    procedure EnableControls;
    procedure StartTimer;
    procedure CalculateTotals;
  public
    { Public declarations }
  end;

var
  frmEditTimes: TfrmEditTimes;

................................................................................
begin
  dtpStart.Time := frmMain.StartTime;
  dtpStop.Time := frmMain.StopTime;
  chkAdjustTimes.Checked := frmMain.UserTimes;
  dtpLunchStart.Time := frmMain.StartLunch;
  dtpLunchStop.Time := frmMain.StopLunch;
  chkAdjustLunch.Checked := frmMain.UserLunch;
  CalculateTotals;
end;

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmEditTimes.StartTimer;
begin
  tmrAutosave.Enabled := False;
  tmrAutosave.Enabled := True;
  CalculateTotals;
end;

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmEditTimes.tmrAutosaveTimer(Sender: TObject);
begin
  tmrAutosave.Enabled := False;
  frmMain.UserTimes := chkAdjustTimes.Checked;
................................................................................
end;

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmEditTimes.btnCloseClick(Sender: TObject);
begin
  Self.Hide;
end;

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmEditTimes.CalculateTotals;
var
  Lunch, Work: TTime;
begin
  Lunch := TimeOf(dtpLunchStop.Time) - TimeOf(dtpLunchStart.Time);
  if Lunch < 0 then
    Lunch := 0;
  lblTimeLunched.Caption := FormatDateTime('HH:mm', Lunch);

  Work := TimeOf(dtpStop.Time) - TimeOf(dtpStart.Time) - Lunch;
  if Work >= 0 then begin
    lblTimeWorked.Caption := FormatDateTime('HH:mm', Work);
  end else begin
    lblTimeWorked.Caption := '-' + FormatDateTime('HH:mm', -Work);
  end;
  if Lunch > 0 then begin
     lblTimeWorked.Caption := lblTimeWorked.Caption + ' (incl. lunch)';
  end;
end;

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmEditTimes.chkAdjustLunchClick(Sender: TObject);
begin
  EnableControls;
  StartTimer;
  frmMain.UserLunch := chkAdjustLunch.Checked;