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