@@ -85,8 +85,9 @@ CWork::CWork() {
85
85
m_fCPUTime = -1.0 ;
86
86
m_fProgress = -1.0 ;
87
87
m_fTimeToCompletion = -1.0 ;
88
- m_tReportDeadline = (time_t )0 ;
89
- m_tEstimatedCompletion = (time_t )0 ;
88
+ m_fDeadlineDiff = -1.0 ;
89
+ m_tReportDeadline = (time_t )-1 ;
90
+ m_tEstimatedCompletion = (time_t )-1 ;
90
91
}
91
92
92
93
@@ -100,6 +101,8 @@ CWork::~CWork() {
100
101
m_strProgress.Clear ();
101
102
m_strTimeToCompletion.Clear ();
102
103
m_strReportDeadline.Clear ();
104
+ m_strEstimatedCompletion.Clear ();
105
+ m_strDeadlineDiff.Clear ();
103
106
}
104
107
105
108
@@ -194,9 +197,9 @@ static bool CompareViewWorkItems(int iRowIndex1, int iRowIndex2) {
194
197
}
195
198
break ;
196
199
case COLUMN_DEADLINEDIFF:
197
- if (work1->m_tDeadlineDiff < work2->m_tDeadlineDiff ) {
200
+ if (work1->m_fDeadlineDiff < work2->m_fDeadlineDiff ) {
198
201
result = -1 ;
199
- } else if (work1->m_tDeadlineDiff > work2->m_tDeadlineDiff ) {
202
+ } else if (work1->m_fDeadlineDiff > work2->m_fDeadlineDiff ) {
200
203
result = 1 ;
201
204
}
202
205
break ;
@@ -1108,18 +1111,11 @@ bool CViewWork::SynchronizeCacheItem(wxInt32 iRowIndex, wxInt32 iColumnIndex) {
1108
1111
}
1109
1112
break ;
1110
1113
case COLUMN_ESTIMATEDCOMPLETION:
1111
- // TODO: NEED TO ADD A WAY TO DISPLAY '---' if the date is the original date.
1112
- // Also todo: Let's change all time_t pointers from 'time' to something else, like 'pt'.
1113
- // Function to pass 0 (to read '---' is: strBuffer = FormatTime(0)
1114
- // TODO: Figure out logic to be most efficient for this case.
1115
- // - what happens if time returned in 0 (because task is not active)
1116
- // - what happens if no change in time
1117
- // -what happens if there is a change in time.
1118
1114
GetDocEstCompletionDate (m_iSortedIndexes[iRowIndex], tDocumentTime);
1119
1115
if (tDocumentTime != work->m_tEstimatedCompletion ) {
1120
1116
work->m_tEstimatedCompletion = tDocumentTime;
1121
1117
if (work->m_tEstimatedCompletion == 0 ) {
1122
- work->m_strEstimatedCompletion << 0 ;
1118
+ work->m_strEstimatedCompletion = _ ( " --- " ) ;
1123
1119
}
1124
1120
else {
1125
1121
FormatDateTime (tDocumentTime, work->m_strEstimatedCompletion );
@@ -1128,11 +1124,23 @@ bool CViewWork::SynchronizeCacheItem(wxInt32 iRowIndex, wxInt32 iColumnIndex) {
1128
1124
}
1129
1125
break ;
1130
1126
case COLUMN_DEADLINEDIFF:
1131
- // something!!!!!!!!!!!!!!!!!!!!!!!!!!!
1132
- // - find estimated completion date
1133
- // - get deadline (should not change...right?
1134
- // make the delta between those.
1135
- // If not equal, store
1127
+ GetDocEstDeadlineDiff (m_iSortedIndexes[iRowIndex], x);
1128
+ if (x != work->m_fDeadlineDiff ) {
1129
+ work->m_fDeadlineDiff = x;
1130
+ if (x < 0 ) {
1131
+ // A negative difference means the task will not meet the
1132
+ // deadline. Because FormatTime does not recognize negative
1133
+ // numbers, the adjustment will be made here.
1134
+ //
1135
+ x *= -1 ;
1136
+ work->m_strDeadlineDiff = _ (" -" );
1137
+ work->m_strDeadlineDiff += FormatTime (x);
1138
+ }
1139
+ else {
1140
+ work->m_strDeadlineDiff = FormatTime (x);
1141
+ }
1142
+ return true ;
1143
+ }
1136
1144
break ;
1137
1145
case COLUMN_STATUS:
1138
1146
int i = m_iSortedIndexes[iRowIndex];
@@ -1285,49 +1293,43 @@ void CViewWork::GetDocTimeToCompletion(wxInt32 item, double& fBuffer) const {
1285
1293
}
1286
1294
1287
1295
1288
- void CViewWork::GetDocReportDeadline (wxInt32 item, time_t & time ) const {
1296
+ void CViewWork::GetDocReportDeadline (wxInt32 item, time_t & tBuffer ) const {
1289
1297
RESULT* result = wxGetApp ().GetDocument ()->result (item);
1290
1298
1291
1299
if (result) {
1292
- time = (time_t )result->report_deadline ;
1300
+ tBuffer = (time_t )result->report_deadline ;
1293
1301
} else {
1294
- time = (time_t )0 ;
1302
+ tBuffer = (time_t )0 ;
1295
1303
}
1296
1304
}
1297
1305
1306
+
1298
1307
// Calculates the estimated date and time a task will be completed.
1299
1308
// This is only calculated for active tasks. If a task is not active,
1300
1309
// time pt will remain at zero. The intent is for the command calling this
1301
1310
// function to use that value to display '---', not the epoch time.
1302
1311
//
1303
- void CViewWork::GetDocEstCompletionDate (wxInt32 item, time_t & pt ) const {
1312
+ void CViewWork::GetDocEstCompletionDate (wxInt32 item, time_t & tBuffer ) const {
1304
1313
RESULT* result = wxGetApp ().GetDocument ()->result (item);
1305
- pt = 0 ;
1314
+ tBuffer = 0 ;
1306
1315
if (result->active_task_state == 1 ) {
1307
1316
time_t ttime = time (0 );
1308
- pt = ttime;
1309
- pt += (time_t )result->estimated_cpu_time_remaining ;
1317
+ tBuffer = ttime;
1318
+ tBuffer += (time_t )result->estimated_cpu_time_remaining ;
1310
1319
}
1320
+ }
1321
+
1311
1322
1312
- // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1313
- // Figure out what "strBuffer" needs to be down below.
1314
- // double check what passing variables need to be.
1315
- // Add function to header
1316
- /* RESULT* result = wxGetApp().GetDocument()->result(m_iSortedIndexes[item]);
1317
- if ((work->m_fCPUTime > 0) && (result->active_task_state == 1)) {
1318
- wxDateTime now = wxDateTime::Now();
1319
- wxTimeSpan time_to_completion = convert_to_timespan(work->m_fTimeToCompletion);
1320
- wxDateTime estimated_completion = now.Add(time_to_completion);
1321
- FormatDateTime(estimated_completion.GetTicks(), strBuffer);
1322
- // Only display the Estimated Completion time if the task has
1323
- // been started and is currently running.
1323
+ void CViewWork::GetDocEstDeadlineDiff (wxInt32 item, double & fBuffer ) const {
1324
+ RESULT* result = wxGetApp ().GetDocument ()->result (item);
1325
+ fBuffer = 0 ;
1326
+ if (result->active_task_state == 1 ) {
1327
+ time_t tdeadline, testcompletion;
1328
+ GetDocEstCompletionDate (item, testcompletion);
1329
+ GetDocReportDeadline (item, tdeadline);
1330
+ fBuffer = (double )(tdeadline - testcompletion);
1324
1331
}
1325
- else {
1326
- strBuffer = FormatTime(0);
1327
- // If the task has not started (CPUTime <= 0) or is not currently
1328
- // running, pass 0 to FormatTime to display "---" as the Estimated
1329
- // Completion time
1330
- }*/
1332
+
1331
1333
}
1332
1334
1333
1335
0 commit comments