@@ -29,36 +29,26 @@ static const int DateTimeMeter_attributes[] = {
2929 DATETIME
3030};
3131
32- static void ClockMeter_updateValues (Meter * this ) {
33- const Machine * host = this -> host ;
34-
35- struct tm result ;
36- const struct tm * lt = localtime_r (& host -> realtime .tv_sec , & result );
37- strftime (this -> txtBuffer , sizeof (this -> txtBuffer ), "%H:%M:%S" , lt );
38- }
39-
40- static void DateMeter_updateValues (Meter * this ) {
41- const Machine * host = this -> host ;
42-
43- struct tm result ;
44- const struct tm * lt = localtime_r (& host -> realtime .tv_sec , & result );
45- strftime (this -> txtBuffer , sizeof (this -> txtBuffer ), "%F" , lt );
46- }
47-
4832static void DateTimeMeter_updateValues (Meter * this ) {
4933 const Machine * host = this -> host ;
5034
5135 struct tm result ;
5236 const struct tm * lt = localtime_r (& host -> realtime .tv_sec , & result );
53- 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+ }
5444}
5545
5646const MeterClass ClockMeter_class = {
5747 .super = {
5848 .extends = Class (Meter ),
5949 .delete = Meter_delete
6050 },
61- .updateValues = ClockMeter_updateValues ,
51+ .updateValues = DateTimeMeter_updateValues ,
6252 .defaultMode = TEXT_METERMODE ,
6353 .supportedModes = (1 << TEXT_METERMODE ) | (1 << LED_METERMODE ),
6454 .maxItems = 0 ,
@@ -74,7 +64,7 @@ const MeterClass DateMeter_class = {
7464 .extends = Class (Meter ),
7565 .delete = Meter_delete
7666 },
77- .updateValues = DateMeter_updateValues ,
67+ .updateValues = DateTimeMeter_updateValues ,
7868 .defaultMode = TEXT_METERMODE ,
7969 .supportedModes = (1 << TEXT_METERMODE ) | (1 << LED_METERMODE ),
8070 .maxItems = 0 ,
0 commit comments