2006-03-04 18:16:49 +00:00
|
|
|
/*
|
2011-12-26 21:35:57 +00:00
|
|
|
htop - ClockMeter.c
|
2011-05-26 16:35:07 +00:00
|
|
|
(C) 2004-2011 Hisham H. Muhammad
|
2020-10-05 07:51:32 +00:00
|
|
|
Released under the GNU GPLv2, see the COPYING file
|
2006-03-04 18:16:49 +00:00
|
|
|
in the source distribution for its full text.
|
|
|
|
*/
|
|
|
|
|
2020-09-19 11:55:23 +00:00
|
|
|
#include "config.h" // IWYU pragma: keep
|
2011-12-26 21:35:57 +00:00
|
|
|
|
2020-09-19 11:55:23 +00:00
|
|
|
#include "ClockMeter.h"
|
2006-03-04 18:16:49 +00:00
|
|
|
|
|
|
|
#include <time.h>
|
|
|
|
|
2020-09-19 11:55:23 +00:00
|
|
|
#include "CRT.h"
|
|
|
|
#include "Object.h"
|
|
|
|
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2020-09-28 10:23:07 +00:00
|
|
|
static const int ClockMeter_attributes[] = {
|
2006-06-06 20:41:01 +00:00
|
|
|
CLOCK
|
|
|
|
};
|
2006-04-10 20:40:38 +00:00
|
|
|
|
2020-10-06 11:13:16 +00:00
|
|
|
static void ClockMeter_updateValues(Meter* this) {
|
2021-03-23 06:27:05 +00:00
|
|
|
const ProcessList* pl = this->pl;
|
|
|
|
|
2014-04-21 21:59:30 +00:00
|
|
|
struct tm result;
|
2021-03-30 04:55:48 +00:00
|
|
|
const struct tm* lt = localtime_r(&pl->realtime.tv_sec, &result);
|
2008-03-09 08:58:38 +00:00
|
|
|
this->values[0] = lt->tm_hour * 60 + lt->tm_min;
|
2020-10-06 11:13:16 +00:00
|
|
|
strftime(this->txtBuffer, sizeof(this->txtBuffer), "%H:%M:%S", lt);
|
2008-03-09 08:58:38 +00:00
|
|
|
}
|
|
|
|
|
2020-10-05 11:19:50 +00:00
|
|
|
const MeterClass ClockMeter_class = {
|
2012-12-05 15:12:20 +00:00
|
|
|
.super = {
|
|
|
|
.extends = Class(Meter),
|
|
|
|
.delete = Meter_delete
|
|
|
|
},
|
2016-05-04 05:39:26 +00:00
|
|
|
.updateValues = ClockMeter_updateValues,
|
2012-12-05 15:12:20 +00:00
|
|
|
.defaultMode = TEXT_METERMODE,
|
2016-03-11 02:54:34 +00:00
|
|
|
.maxItems = 1,
|
2015-08-28 08:13:11 +00:00
|
|
|
.total = 1440, /* 24*60 */
|
2006-04-10 20:40:38 +00:00
|
|
|
.attributes = ClockMeter_attributes,
|
|
|
|
.name = "Clock",
|
|
|
|
.uiName = "Clock",
|
|
|
|
.caption = "Time: ",
|
2006-03-04 18:16:49 +00:00
|
|
|
};
|