summaryrefslogtreecommitdiff
path: root/src/systemadm.vala
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2011-02-23 14:03:59 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2011-09-19 10:03:37 +0200
commit8401f1533d6936add337a621c5e58e3bbe9f346a (patch)
tree192debd017898cf1435295559ea52e0c6a592d2b /src/systemadm.vala
parent0e89268b285657bf1b52cebb12fe42b5ac630582 (diff)
systemadm: break timestamp formatting out into a seperate function
Since the timezone is always local, it doesn't make much sense to display it. The timestamp is now formatted without the timezone. I guess it can be further improved, which should be easier now that it is tucked-away in a separate function.
Diffstat (limited to 'src/systemadm.vala')
-rw-r--r--src/systemadm.vala24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/systemadm.vala b/src/systemadm.vala
index d45ec64ca4..988e9f173c 100644
--- a/src/systemadm.vala
+++ b/src/systemadm.vala
@@ -23,6 +23,13 @@ using Pango;
static bool user = false;
+public string format_time(uint64 time_ns) {
+ if (time_ns <= 0)
+ return "";
+ Time timestamp = Time.local((time_t) (time_ns / 1000000));
+ return timestamp.format("%a, %d %b %Y %H:%M:%S");
+}
+
public class LeftLabel : Label {
public LeftLabel(string? text = null) {
if (text != null)
@@ -515,19 +522,10 @@ public class MainWindow : Window {
else
unit_fragment_path_label.set_text_or_na();
- uint64 t = unit.active_enter_timestamp;
- if (t > 0) {
- Time timestamp = Time.local((time_t) (t / 1000000));
- unit_active_enter_timestamp_label.set_text_or_na(timestamp.format("%a, %d %b %Y %H:%M:%S %z"));
- } else
- unit_active_enter_timestamp_label.set_text_or_na();
-
- t = unit.active_exit_timestamp;
- if (t > 0) {
- Time timestamp = Time.local((time_t) (t / 1000000));
- unit_active_exit_timestamp_label.set_text_or_na(timestamp.format("%a, %d %b %Y %H:%M:%S %z"));
- } else
- unit_active_exit_timestamp_label.set_text_or_na();
+
+ unit_active_enter_timestamp_label.set_text_or_na(format_time(unit.active_enter_timestamp));
+
+ unit_active_exit_timestamp_label.set_text_or_na(format_time(unit.active_exit_timestamp));
bool b = unit.can_start;
start_button.set_sensitive(b);