Skip to content

Commit 7f66716

Browse files
Daniel LangeDaniel Lange
authored andcommitted
Merge branch 'date-time-meter-merge' of Explorer09/htop-1
2 parents 907db44 + fb642b0 commit 7f66716

14 files changed

Lines changed: 30 additions & 82 deletions

File tree

ClockMeter.c

Lines changed: 0 additions & 46 deletions
This file was deleted.

ClockMeter.h

Lines changed: 0 additions & 15 deletions
This file was deleted.

DateTimeMeter.c

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ in the source distribution for its full text.
1717
#include "Object.h"
1818

1919

20+
static const int ClockMeter_attributes[] = {
21+
CLOCK
22+
};
23+
2024
static const int DateMeter_attributes[] = {
2125
DATE
2226
};
@@ -25,28 +29,42 @@ static const int DateTimeMeter_attributes[] = {
2529
DATETIME
2630
};
2731

28-
static void DateMeter_updateValues(Meter* this) {
29-
const Machine* host = this->host;
30-
31-
struct tm result;
32-
const struct tm* lt = localtime_r(&host->realtime.tv_sec, &result);
33-
strftime(this->txtBuffer, sizeof(this->txtBuffer), "%F", lt);
34-
}
35-
3632
static void DateTimeMeter_updateValues(Meter* this) {
3733
const Machine* host = this->host;
3834

3935
struct tm result;
4036
const struct tm* lt = localtime_r(&host->realtime.tv_sec, &result);
41-
strftime(this->txtBuffer, sizeof(this->txtBuffer), "%F %H:%M:%S", lt);
37+
if (As_Meter(this) == &ClockMeter_class) {
38+
strftime(this->txtBuffer, sizeof(this->txtBuffer), "%H:%M:%S", lt);
39+
} else if (As_Meter(this) == &DateMeter_class) {
40+
strftime(this->txtBuffer, sizeof(this->txtBuffer), "%F", lt);
41+
} else {
42+
strftime(this->txtBuffer, sizeof(this->txtBuffer), "%F %H:%M:%S", lt);
43+
}
4244
}
4345

46+
const MeterClass ClockMeter_class = {
47+
.super = {
48+
.extends = Class(Meter),
49+
.delete = Meter_delete
50+
},
51+
.updateValues = DateTimeMeter_updateValues,
52+
.defaultMode = TEXT_METERMODE,
53+
.supportedModes = (1 << TEXT_METERMODE) | (1 << LED_METERMODE),
54+
.maxItems = 0,
55+
.total = 0.0,
56+
.attributes = ClockMeter_attributes,
57+
.name = "Clock",
58+
.uiName = "Clock",
59+
.caption = "Time: ",
60+
};
61+
4462
const MeterClass DateMeter_class = {
4563
.super = {
4664
.extends = Class(Meter),
4765
.delete = Meter_delete
4866
},
49-
.updateValues = DateMeter_updateValues,
67+
.updateValues = DateTimeMeter_updateValues,
5068
.defaultMode = TEXT_METERMODE,
5169
.supportedModes = (1 << TEXT_METERMODE) | (1 << LED_METERMODE),
5270
.maxItems = 0,

DateTimeMeter.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ in the source distribution for its full text.
1010
#include "Meter.h"
1111

1212

13+
extern const MeterClass ClockMeter_class;
14+
1315
extern const MeterClass DateMeter_class;
1416

1517
extern const MeterClass DateTimeMeter_class;

Makefile.am

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ myhtopsources = \
3535
AvailableMetersPanel.c \
3636
BatteryMeter.c \
3737
CategoriesPanel.c \
38-
ClockMeter.c \
3938
ColorsPanel.c \
4039
ColumnsPanel.c \
4140
CommandLine.c \
@@ -103,7 +102,6 @@ myhtopheaders = \
103102
CPUMeter.h \
104103
CRT.h \
105104
CategoriesPanel.h \
106-
ClockMeter.h \
107105
ColorsPanel.h \
108106
ColumnsPanel.h \
109107
CommandLine.h \

darwin/Platform.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ in the source distribution for its full text.
3333
#include <IOKit/ps/IOPSKeys.h>
3434
#include <IOKit/storage/IOBlockStorageDriver.h>
3535

36-
#include "ClockMeter.h"
3736
#include "CPUMeter.h"
3837
#include "CRT.h"
3938
#include "DateTimeMeter.h"

dragonflybsd/Platform.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ in the source distribution for its full text.
2222
#include <sys/types.h>
2323
#include <vm/vm_param.h>
2424

25-
#include "ClockMeter.h"
2625
#include "CPUMeter.h"
2726
#include "DateTimeMeter.h"
2827
#include "FileDescriptorMeter.h"

freebsd/Platform.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ in the source distribution for its full text.
2727
#include <vm/vm_param.h>
2828

2929
#include "CPUMeter.h"
30-
#include "ClockMeter.h"
3130
#include "DateTimeMeter.h"
3231
#include "DiskIOMeter.h"
3332
#include "FileDescriptorMeter.h"

linux/Platform.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ in the source distribution for its full text.
2424
#include <sys/sysmacros.h>
2525

2626
#include "BatteryMeter.h"
27-
#include "ClockMeter.h"
2827
#include "CPUMeter.h"
2928
#include "DateTimeMeter.h"
3029
#include "DiskIOMeter.h"

netbsd/Platform.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ in the source distribution for its full text.
3737
#include <sys/types.h>
3838

3939
#include "CPUMeter.h"
40-
#include "ClockMeter.h"
4140
#include "DateTimeMeter.h"
4241
#include "FileDescriptorMeter.h"
4342
#include "HostnameMeter.h"

0 commit comments

Comments
 (0)