Skip to content

Commit

Permalink
Support %f as a moving clock face
Browse files Browse the repository at this point in the history
  • Loading branch information
dsboger committed Apr 27, 2017
1 parent 902c608 commit 5941974
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,24 @@ function overrider(lbl) {
var FORMAT = settings.get_string("override-string");
var desired = FORMAT;
if (FORMAT.indexOf("%") > -1) {
desired = GLib.DateTime.new_now_local().format(FORMAT);
var now = GLib.DateTime.new_now_local();
if (FORMAT.indexOf("%f") > -1) {
var hour = now.get_hour();
// convert from 0-23 to 1-12
if (hour > 12) {
hour -= 12;
}
if (hour == 0) {
hour = 12;
}
var clockFaceCodePoint = 0x1f550 + (hour - 1);
var minute = now.get_minute();
if (minute >= 30) {
clockFaceCodePoint += 12;
}
desired = desired.replace("%f", String.fromCodePoint(clockFaceCodePoint));
}
desired = now.format(desired);
}
if (t != desired) {
last = t;
Expand Down

0 comments on commit 5941974

Please sign in to comment.