Skip to content

Commit 759f71e

Browse files
mm-chenwattnpapa
authored andcommitted
add varible date format (ktt-ol#11)
* Update README.md * add DATE-FORMAT * add varible date format
1 parent 3e3ce2e commit 759f71e

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

example.cfg

+2
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,5 @@ broker = mqtt.server.exaple.com
3737
topic = /exaple/topic
3838
displayOn = open
3939
displayOff = close
40+
[DATE-FORMAT]
41+
format = %Y-%m-%d

src/curses-ui/clock.vala

+6-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ using Curses;
1818
public class ClockWindow {
1919
AsciiNumbers ascii;
2020
Window win;
21+
string dateformat;
22+
Config cfg;
2123

2224
public ClockWindow() {
2325
ascii = new AsciiNumbers();
@@ -26,6 +28,9 @@ public class ClockWindow {
2628

2729
win.clrtobot();
2830
win.box(0, 0);
31+
32+
cfg = Bus.get_proxy_sync(BusType.SYSTEM, "io.mainframe.shopsystem.Config", "/io/mainframe/shopsystem/config");
33+
dateformat = cfg.get_string("DATE-FORMAT", "format");
2934

3035
win.refresh();
3136
}
@@ -63,7 +68,7 @@ public class ClockWindow {
6368
win.clrtobot();
6469
win.box(0, 0);
6570

66-
win.mvaddstr(5,4, now.format("%Y-%m-%d"));
71+
win.mvaddstr(5,4, now.format(dateformat));
6772

6873
win.refresh();
6974
}

0 commit comments

Comments
 (0)