summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog.adoc1
-rw-r--r--doc/de/autogen/plugin_api/infos.adoc2
-rw-r--r--doc/en/autogen/plugin_api/infos.adoc2
-rw-r--r--doc/fr/autogen/plugin_api/infos.adoc2
-rw-r--r--doc/it/autogen/plugin_api/infos.adoc2
-rw-r--r--doc/ja/autogen/plugin_api/infos.adoc2
-rw-r--r--doc/pl/autogen/plugin_api/infos.adoc2
-rw-r--r--po/cs.po8
-rw-r--r--po/de.po8
-rw-r--r--po/es.po8
-rw-r--r--po/fr.po14
-rw-r--r--po/hu.po8
-rw-r--r--po/it.po8
-rw-r--r--po/ja.po8
-rw-r--r--po/pl.po36
-rw-r--r--po/pt.po8
-rw-r--r--po/pt_BR.po8
-rw-r--r--po/ru.po8
-rw-r--r--po/tr.po8
-rw-r--r--po/weechat.pot8
-rw-r--r--src/core/wee-command.c39
-rw-r--r--src/core/wee-util.c24
-rw-r--r--src/core/wee-util.h2
-rw-r--r--src/plugins/plugin-api.c51
24 files changed, 218 insertions, 49 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc
index 6ded64a74..68acd0b59 100644
--- a/ChangeLog.adoc
+++ b/ChangeLog.adoc
@@ -24,6 +24,7 @@ New features::
* core: add optional command prefix in completion templates "commands", "plugins_commands" and ""weechat_commands"
* core: add optional arguments in completion template, sent to the callback
* core: add option "time" in command /debug
+ * api: add info "uptime" (WeeChat uptime)
* api: add info "pid" (WeeChat PID) (issue #850)
* fifo: add file fifo.conf and option fifo.file.path to customize FIFO pipe path/filename (issue #850)
* irc: add server option "usermode" (issue #377, issue #820)
diff --git a/doc/de/autogen/plugin_api/infos.adoc b/doc/de/autogen/plugin_api/infos.adoc
index 29b28d322..2b94c0b62 100644
--- a/doc/de/autogen/plugin_api/infos.adoc
+++ b/doc/de/autogen/plugin_api/infos.adoc
@@ -64,6 +64,8 @@
| weechat | term_width | Breite des Terminals | -
+| weechat | uptime | WeeChat uptime (format: "days:hh:mm:ss") | "days" (number of days) or "seconds" (number of seconds) (optional)
+
| weechat | version | WeeChat-Version | -
| weechat | version_git | WeeChat Git Version (Ausgabe des Befehls "git describe", ausschließlich für eine Entwicklerversion. Eine stabile Version gibt keine Information zurück) | -
diff --git a/doc/en/autogen/plugin_api/infos.adoc b/doc/en/autogen/plugin_api/infos.adoc
index 6ce9b2753..8f0333f04 100644
--- a/doc/en/autogen/plugin_api/infos.adoc
+++ b/doc/en/autogen/plugin_api/infos.adoc
@@ -64,6 +64,8 @@
| weechat | term_width | width of terminal | -
+| weechat | uptime | WeeChat uptime (format: "days:hh:mm:ss") | "days" (number of days) or "seconds" (number of seconds) (optional)
+
| weechat | version | WeeChat version | -
| weechat | version_git | WeeChat git version (output of command "git describe" for a development version only, empty for a stable release) | -
diff --git a/doc/fr/autogen/plugin_api/infos.adoc b/doc/fr/autogen/plugin_api/infos.adoc
index ea8133ebc..7dadbf0e6 100644
--- a/doc/fr/autogen/plugin_api/infos.adoc
+++ b/doc/fr/autogen/plugin_api/infos.adoc
@@ -64,6 +64,8 @@
| weechat | term_width | largeur du terminal | -
+| weechat | uptime | Uptime de WeeChat (format : "jours:hh:mm:ss") | "days" (nombre de jours) ou "seconds" (nombre de secondes) (optionnel)
+
| weechat | version | version de WeeChat | -
| weechat | version_git | version git de WeeChat (sortie de la commande "git describe" pour une version de développement seulement, vide pour une version stable) | -
diff --git a/doc/it/autogen/plugin_api/infos.adoc b/doc/it/autogen/plugin_api/infos.adoc
index 8d74d79c6..2b04df954 100644
--- a/doc/it/autogen/plugin_api/infos.adoc
+++ b/doc/it/autogen/plugin_api/infos.adoc
@@ -64,6 +64,8 @@
| weechat | term_width | width of terminal | -
+| weechat | uptime | WeeChat uptime (format: "days:hh:mm:ss") | "days" (number of days) or "seconds" (number of seconds) (optional)
+
| weechat | version | versione di WeeChat | -
| weechat | version_git | Versione git di weechat (output del comando "git describe" solo per la versione di sviluppo, vuoto per una release stabile) | -
diff --git a/doc/ja/autogen/plugin_api/infos.adoc b/doc/ja/autogen/plugin_api/infos.adoc
index bf4420d73..517689aeb 100644
--- a/doc/ja/autogen/plugin_api/infos.adoc
+++ b/doc/ja/autogen/plugin_api/infos.adoc
@@ -64,6 +64,8 @@
| weechat | term_width | 端末の幅 | -
+| weechat | uptime | WeeChat uptime (format: "days:hh:mm:ss") | "days" (number of days) or "seconds" (number of seconds) (optional)
+
| weechat | version | WeeChat のバージョン | -
| weechat | version_git | WeeChat の git バージョン (開発バージョンではコマンド "git describe" の出力、安定版リリースでは空文字が出力されます) | -
diff --git a/doc/pl/autogen/plugin_api/infos.adoc b/doc/pl/autogen/plugin_api/infos.adoc
index 91061f451..cfcedc395 100644
--- a/doc/pl/autogen/plugin_api/infos.adoc
+++ b/doc/pl/autogen/plugin_api/infos.adoc
@@ -64,6 +64,8 @@
| weechat | term_width | szerokość terminala | -
+| weechat | uptime | WeeChat uptime (format: "days:hh:mm:ss") | "days" (number of days) or "seconds" (number of seconds) (optional)
+
| weechat | version | wersja WeeChat | -
| weechat | version_git | wersja git WeeChat (wyjście komendy "git describe" dla tylko dla wersji rozwojowej, puste dla wersji stabilnej) | -
diff --git a/po/cs.po b/po/cs.po
index 988a62adc..a67878c3b 100644
--- a/po/cs.po
+++ b/po/cs.po
@@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2016-12-20 22:37+0100\n"
+"POT-Creation-Date: 2016-12-31 18:22+0100\n"
"PO-Revision-Date: 2016-09-03 08:23+0200\n"
"Last-Translator: Ondřej Súkup <mimi.vx@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -9008,6 +9008,12 @@ msgstr "získat kód barvy přezdívky"
msgid "get nick color name"
msgstr "získat jméno barvy přezdívky"
+msgid "WeeChat uptime (format: \"days:hh:mm:ss\")"
+msgstr ""
+
+msgid "\"days\" (number of days) or \"seconds\" (number of seconds) (optional)"
+msgstr ""
+
msgid "list of bars"
msgstr "seznam polí"
diff --git a/po/de.po b/po/de.po
index 2f31da02f..0442f1535 100644
--- a/po/de.po
+++ b/po/de.po
@@ -19,7 +19,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2016-12-20 22:37+0100\n"
+"POT-Creation-Date: 2016-12-31 18:22+0100\n"
"PO-Revision-Date: 2016-12-21 08:26+0100\n"
"Last-Translator: Nils Görs <weechatter@arcor.de>\n"
"Language-Team: German <kde-i18n-de@kde.org>\n"
@@ -10353,6 +10353,12 @@ msgstr "zeigt Farbecode des Nick"
msgid "get nick color name"
msgstr "zeigt Farbnamen des Nick"
+msgid "WeeChat uptime (format: \"days:hh:mm:ss\")"
+msgstr ""
+
+msgid "\"days\" (number of days) or \"seconds\" (number of seconds) (optional)"
+msgstr ""
+
msgid "list of bars"
msgstr "Auflistung der Bars"
diff --git a/po/es.po b/po/es.po
index 1bad3d817..cbb3c9687 100644
--- a/po/es.po
+++ b/po/es.po
@@ -22,7 +22,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2016-12-20 22:37+0100\n"
+"POT-Creation-Date: 2016-12-31 18:22+0100\n"
"PO-Revision-Date: 2016-09-03 08:23+0200\n"
"Last-Translator: Elián Hanisch <lambdae2@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -9314,6 +9314,12 @@ msgstr "obtiene el código del color del apodo"
msgid "get nick color name"
msgstr "obtiene el nombre del color del apodo"
+msgid "WeeChat uptime (format: \"days:hh:mm:ss\")"
+msgstr ""
+
+msgid "\"days\" (number of days) or \"seconds\" (number of seconds) (optional)"
+msgstr ""
+
msgid "list of bars"
msgstr "lista de barras"
diff --git a/po/fr.po b/po/fr.po
index d64adc1bf..0a506006e 100644
--- a/po/fr.po
+++ b/po/fr.po
@@ -21,8 +21,8 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2016-12-20 22:37+0100\n"
-"PO-Revision-Date: 2016-12-20 22:37+0100\n"
+"POT-Creation-Date: 2016-12-31 18:22+0100\n"
+"PO-Revision-Date: 2016-12-31 18:22+0100\n"
"Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"Language: fr\n"
@@ -10108,6 +10108,13 @@ msgstr "retourne le code couleur du pseudo"
msgid "get nick color name"
msgstr "retourne le nom de la couleur du pseudo"
+msgid "WeeChat uptime (format: \"days:hh:mm:ss\")"
+msgstr "Uptime de WeeChat (format : \"jours:hh:mm:ss\")"
+
+msgid "\"days\" (number of days) or \"seconds\" (number of seconds) (optional)"
+msgstr ""
+"\"days\" (nombre de jours) ou \"seconds\" (nombre de secondes) (optionnel)"
+
msgid "list of bars"
msgstr "liste des barres"
@@ -12761,6 +12768,9 @@ msgstr "%s%s : délai d'attente dépassé pour \"%s\" avec %s"
msgid "%s%s: unable to connect: unexpected error (%d)"
msgstr "%s%s : impossible de se connecter : erreur inattendue (%d)"
+#~ msgid "\"days\" (optional: just return the number of days)"
+#~ msgstr "\"days\" (optionnel : retourner juste le nombre de jours)"
+
#~ msgid "commands defined by plugins"
#~ msgstr "commandes définies par les extensions"
diff --git a/po/hu.po b/po/hu.po
index cdd1402e5..00da7a198 100644
--- a/po/hu.po
+++ b/po/hu.po
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2016-12-20 22:37+0100\n"
+"POT-Creation-Date: 2016-12-31 18:22+0100\n"
"PO-Revision-Date: 2016-09-03 08:23+0200\n"
"Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -8366,6 +8366,12 @@ msgstr "üzenetek színe"
msgid "get nick color name"
msgstr "üzenetek színe"
+msgid "WeeChat uptime (format: \"days:hh:mm:ss\")"
+msgstr ""
+
+msgid "\"days\" (number of days) or \"seconds\" (number of seconds) (optional)"
+msgstr ""
+
#, fuzzy
msgid "list of bars"
msgstr "Aliaszok listája:\n"
diff --git a/po/it.po b/po/it.po
index 6ddf0be01..5426d3e77 100644
--- a/po/it.po
+++ b/po/it.po
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2016-12-20 22:37+0100\n"
+"POT-Creation-Date: 2016-12-31 18:22+0100\n"
"PO-Revision-Date: 2016-09-03 08:24+0200\n"
"Last-Translator: Esteban I. Ruiz Moreno <exio4.com@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -9477,6 +9477,12 @@ msgstr "ottiene il codice del colore del nick"
msgid "get nick color name"
msgstr "ottiene il nome del colore del nick"
+msgid "WeeChat uptime (format: \"days:hh:mm:ss\")"
+msgstr ""
+
+msgid "\"days\" (number of days) or \"seconds\" (number of seconds) (optional)"
+msgstr ""
+
msgid "list of bars"
msgstr "elenco delle barre"
diff --git a/po/ja.po b/po/ja.po
index c59319128..34b6e11cf 100644
--- a/po/ja.po
+++ b/po/ja.po
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2016-12-20 22:37+0100\n"
+"POT-Creation-Date: 2016-12-31 18:22+0100\n"
"PO-Revision-Date: 2016-12-24 09:00+0900\n"
"Last-Translator: AYANOKOUZI, Ryuunosuke <i38w7i3@yahoo.co.jp>\n"
"Language-Team: Japanese <https://github.com/l/weechat/tree/master/"
@@ -9718,6 +9718,12 @@ msgstr "ニックネームの色コードを取得"
msgid "get nick color name"
msgstr "ニックネームの色名を取得"
+msgid "WeeChat uptime (format: \"days:hh:mm:ss\")"
+msgstr ""
+
+msgid "\"days\" (number of days) or \"seconds\" (number of seconds) (optional)"
+msgstr ""
+
msgid "list of bars"
msgstr "バーのリスト"
diff --git a/po/pl.po b/po/pl.po
index 923b9f437..b415c30de 100644
--- a/po/pl.po
+++ b/po/pl.po
@@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2016-12-20 22:37+0100\n"
+"POT-Creation-Date: 2016-12-31 18:22+0100\n"
"PO-Revision-Date: 2016-12-31 12:37+0100\n"
"Last-Translator: Krzysztof Korościk <soltys@soltys.info>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1793,11 +1793,11 @@ msgstr ""
"Najczęściej używane tagi:\n"
" no_filter, no_highlight, no_log, log0..log9 (log level),\n"
" notify_none, notify_message, notify_private, notify_highlight,\n"
-" self_msg, nick_xxx (xxx to nick w wiadomości), prefix_nick_ccc "
-"(ccc to kolor nicka),\n"
+" self_msg, nick_xxx (xxx to nick w wiadomości), prefix_nick_ccc (ccc to "
+"kolor nicka),\n"
" host_xxx (xxx to użytkownik + host w wiadomości),\n"
-" irc_xxx (xxx to nazwa komendy, lub numer; zobacz /server raw lub "
-"/debug tags),\n"
+" irc_xxx (xxx to nazwa komendy, lub numer; zobacz /server raw lub /debug "
+"tags),\n"
" irc_numeric, irc_error, irc_action, irc_ctcp, irc_ctcp_reply, "
"irc_smart_filter, away_info.\n"
"Aby zobaczyć listę tagów w liniach buforów wykonaj: /debug tags\n"
@@ -3105,7 +3105,8 @@ msgid "values for a configuration option"
msgstr "wartości opcji konfiguracyjnych"
msgid "weechat commands; optional argument: prefix to add before the commands"
-msgstr "komendy weechat: opcjonalny argument: prefiks do dodania przed komendami"
+msgstr ""
+"komendy weechat: opcjonalny argument: prefiks do dodania przed komendami"
msgid "names of proxies"
msgstr "nazwy proxy"
@@ -5892,10 +5893,10 @@ msgid ""
"home (\"~/.weechat\" by default); WeeChat PID can be used in path with "
"${info:pid} (note: content is evaluated, see /help eval)"
msgstr ""
-"ścieżka dla pliku FIFO; \"%h\" na początku ciągu zostanie zastąpione "
-"przez katalog domowy WeeChat (domyślnie \"~/.weechat\"); PID WeeChat może"
-"zostać użyty poprzez ${info:pid} (uwaga: zawartość jest przetwarzana, "
-"zobacz /help eval)"
+"ścieżka dla pliku FIFO; \"%h\" na początku ciągu zostanie zastąpione przez "
+"katalog domowy WeeChat (domyślnie \"~/.weechat\"); PID WeeChat możezostać "
+"użyty poprzez ${info:pid} (uwaga: zawartość jest przetwarzana, zobacz /help "
+"eval)"
msgid "name of FIFO pipe"
msgstr "nazwa strumienia FIFO"
@@ -7787,7 +7788,8 @@ msgid "check that the SSL connection is fully trusted"
msgstr "sprawdź czy połączenie ssl jest w pełni zaufane"
msgid "password for server (note: content is evaluated, see /help eval)"
-msgstr "hasło dla serwera (uwaga: zawartość jest przetwarzana, zobacz /help eval)"
+msgstr ""
+"hasło dla serwera (uwaga: zawartość jest przetwarzana, zobacz /help eval)"
#. TRANSLATORS: please keep words "client capabilities" between brackets if translation is different (see fr.po)
msgid ""
@@ -7906,9 +7908,9 @@ msgid ""
msgstr ""
"tryb(y) użytkowniak do ustawienia po połączeniu z serwerem przed wykonaniem "
"komend oraz automatycznym wejściem na kanały; przykłady \"+R\" (w celu "
-"ustawienia trybu \"R\"), \"+R-i\" (w celu utawienia trbu \"R\" i zdjęcia trybu "
-"\"i\"); zobacz /help mode dla pełnej lity składni (uwaga: zawartość jest "
-"przetwarzana, zobacz /help eval)"
+"ustawienia trybu \"R\"), \"+R-i\" (w celu utawienia trbu \"R\" i zdjęcia "
+"trybu \"i\"); zobacz /help mode dla pełnej lity składni (uwaga: zawartość "
+"jest przetwarzana, zobacz /help eval)"
msgid ""
"command(s) to run after connection to server and before auto-join of "
@@ -9907,6 +9909,12 @@ msgstr "pobiera kod koloru nicka"
msgid "get nick color name"
msgstr "pobiera nazwę koloru nicka"
+msgid "WeeChat uptime (format: \"days:hh:mm:ss\")"
+msgstr ""
+
+msgid "\"days\" (number of days) or \"seconds\" (number of seconds) (optional)"
+msgstr ""
+
msgid "list of bars"
msgstr "lista pasków"
diff --git a/po/pt.po b/po/pt.po
index 37246ac4c..8c57d4016 100644
--- a/po/pt.po
+++ b/po/pt.po
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2016-12-20 22:37+0100\n"
+"POT-Creation-Date: 2016-12-31 18:22+0100\n"
"PO-Revision-Date: 2016-09-27 12:29+0000\n"
"Last-Translator: Vasco Almeida <vascomalmeida@sapo.pt>\n"
"Language-Team: Portuguese <>\n"
@@ -9908,6 +9908,12 @@ msgstr "obter código de cor do nick"
msgid "get nick color name"
msgstr "obter nome da cor do nick"
+msgid "WeeChat uptime (format: \"days:hh:mm:ss\")"
+msgstr ""
+
+msgid "\"days\" (number of days) or \"seconds\" (number of seconds) (optional)"
+msgstr ""
+
msgid "list of bars"
msgstr "lista de barras"
diff --git a/po/pt_BR.po b/po/pt_BR.po
index 24f6ef525..d3358cf22 100644
--- a/po/pt_BR.po
+++ b/po/pt_BR.po
@@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2016-12-20 22:37+0100\n"
+"POT-Creation-Date: 2016-12-31 18:22+0100\n"
"PO-Revision-Date: 2016-09-03 08:24+0200\n"
"Last-Translator: Eduardo Elias <camponez@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -8810,6 +8810,12 @@ msgstr "obter código de cor do apelido"
msgid "get nick color name"
msgstr "obter nome da cor do apelido"
+msgid "WeeChat uptime (format: \"days:hh:mm:ss\")"
+msgstr ""
+
+msgid "\"days\" (number of days) or \"seconds\" (number of seconds) (optional)"
+msgstr ""
+
msgid "list of bars"
msgstr "lista de barras"
diff --git a/po/ru.po b/po/ru.po
index 67216f961..161803209 100644
--- a/po/ru.po
+++ b/po/ru.po
@@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2016-12-20 22:37+0100\n"
+"POT-Creation-Date: 2016-12-31 18:22+0100\n"
"PO-Revision-Date: 2016-09-03 08:24+0200\n"
"Last-Translator: Aleksey V Zapparov AKA ixti <ixti@member.fsf.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -8403,6 +8403,12 @@ msgstr "цвет чата"
msgid "get nick color name"
msgstr "цвет чата"
+msgid "WeeChat uptime (format: \"days:hh:mm:ss\")"
+msgstr ""
+
+msgid "\"days\" (number of days) or \"seconds\" (number of seconds) (optional)"
+msgstr ""
+
#, fuzzy
msgid "list of bars"
msgstr "Список сокращений:\n"
diff --git a/po/tr.po b/po/tr.po
index 1ed10846f..a2c937e15 100644
--- a/po/tr.po
+++ b/po/tr.po
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2016-12-20 22:37+0100\n"
+"POT-Creation-Date: 2016-12-31 18:22+0100\n"
"PO-Revision-Date: 2016-05-18 07:43+0200\n"
"Last-Translator: Hasan Kiran <sunder67@hotmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -7590,6 +7590,12 @@ msgstr "rumuz renk kodu al"
msgid "get nick color name"
msgstr "rumuz renk ismi al"
+msgid "WeeChat uptime (format: \"days:hh:mm:ss\")"
+msgstr ""
+
+msgid "\"days\" (number of days) or \"seconds\" (number of seconds) (optional)"
+msgstr ""
+
msgid "list of bars"
msgstr ""
diff --git a/po/weechat.pot b/po/weechat.pot
index 1e45e9e18..0edf371c9 100644
--- a/po/weechat.pot
+++ b/po/weechat.pot
@@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2016-12-20 22:37+0100\n"
+"POT-Creation-Date: 2016-12-31 18:22+0100\n"
"PO-Revision-Date: 2014-08-16 10:27+0200\n"
"Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -7514,6 +7514,12 @@ msgstr ""
msgid "get nick color name"
msgstr ""
+msgid "WeeChat uptime (format: \"days:hh:mm:ss\")"
+msgstr ""
+
+msgid "\"days\" (number of days) or \"seconds\" (number of seconds) (optional)"
+msgstr ""
+
msgid "list of bars"
msgstr ""
diff --git a/src/core/wee-command.c b/src/core/wee-command.c
index dee891cf7..2ed98a250 100644
--- a/src/core/wee-command.c
+++ b/src/core/wee-command.c
@@ -6185,8 +6185,7 @@ COMMAND_CALLBACK(upgrade)
COMMAND_CALLBACK(uptime)
{
- time_t running_time;
- int day, hour, min, sec;
+ int days, hours, minutes, seconds;
char string[512];
/* make C compiler happy */
@@ -6194,21 +6193,17 @@ COMMAND_CALLBACK(uptime)
(void) data;
(void) argv_eol;
- running_time = time (NULL) - weechat_first_start_time;
- day = running_time / (60 * 60 * 24);
- hour = (running_time % (60 * 60 * 24)) / (60 * 60);
- min = ((running_time % (60 * 60 * 24)) % (60 * 60)) / 60;
- sec = ((running_time % (60 * 60 * 24)) % (60 * 60)) % 60;
+ util_get_uptime (NULL, &days, &hours, &minutes, &seconds);
if ((argc >= 2) && (string_strcasecmp (argv[1], "-o") == 0))
{
snprintf (string, sizeof (string),
"WeeChat uptime: %d %s %02d:%02d:%02d, started on %s",
- day,
- (day != 1) ? "days" : "day",
- hour,
- min,
- sec,
+ days,
+ (days != 1) ? "days" : "day",
+ hours,
+ minutes,
+ seconds,
ctime (&weechat_first_start_time));
string[strlen (string) - 1] = '\0';
(void) input_data (buffer, string);
@@ -6218,11 +6213,11 @@ COMMAND_CALLBACK(uptime)
snprintf (string, sizeof (string),
/* TRANSLATORS: "%s" after "started on" is a date */
_("WeeChat uptime: %d %s %02d:%02d:%02d, started on %s"),
- day,
- NG_("day", "days", day),
- hour,
- min,
- sec,
+ days,
+ NG_("day", "days", days),
+ hours,
+ minutes,
+ seconds,
util_get_time_string (&weechat_first_start_time));
(void) input_data (buffer, string);
}
@@ -6234,17 +6229,17 @@ COMMAND_CALLBACK(uptime)
"%s%02d%s:%s%02d%s:%s%02d%s, "
"started on %s%s"),
GUI_COLOR(GUI_COLOR_CHAT_BUFFER),
- day,
+ days,
GUI_COLOR(GUI_COLOR_CHAT),
- NG_("day", "days", day),
+ NG_("day", "days", days),
GUI_COLOR(GUI_COLOR_CHAT_BUFFER),
- hour,
+ hours,
GUI_COLOR(GUI_COLOR_CHAT),
GUI_COLOR(GUI_COLOR_CHAT_BUFFER),
- min,
+ minutes,
GUI_COLOR(GUI_COLOR_CHAT),
GUI_COLOR(GUI_COLOR_CHAT_BUFFER),
- sec,
+ seconds,
GUI_COLOR(GUI_COLOR_CHAT),
GUI_COLOR(GUI_COLOR_CHAT_BUFFER),
util_get_time_string (&weechat_first_start_time));
diff --git a/src/core/wee-util.c b/src/core/wee-util.c
index 0dccb1861..4716956f2 100644
--- a/src/core/wee-util.c
+++ b/src/core/wee-util.c
@@ -766,3 +766,27 @@ util_version_number (const char *version)
return (version_int[0] << 24) | (version_int[1] << 16)
| (version_int[2] << 8) | version_int[3];
}
+
+/*
+ * Return uptime as number of days, hours, minutes, seconds.
+ */
+
+void
+util_get_uptime (time_t *total_seconds, int *days,
+ int *hours, int *minutes, int *seconds)
+{
+ time_t running_time;
+
+ running_time = time (NULL) - weechat_first_start_time;
+
+ if (total_seconds)
+ *total_seconds = running_time;
+ if (days)
+ *days = running_time / (60 * 60 * 24);
+ if (hours)
+ *hours = (running_time % (60 * 60 * 24)) / (60 * 60);
+ if (minutes)
+ *minutes = ((running_time % (60 * 60 * 24)) % (60 * 60)) / 60;
+ if (seconds)
+ *seconds = ((running_time % (60 * 60 * 24)) % (60 * 60)) % 60;
+}
diff --git a/src/core/wee-util.h b/src/core/wee-util.h
index 47a24575f..e03c7a815 100644
--- a/src/core/wee-util.h
+++ b/src/core/wee-util.h
@@ -52,5 +52,7 @@ extern char *util_search_full_lib_name (const char *filename,
const char *sys_directory);
extern char *util_file_get_content (const char *filename);
extern int util_version_number (const char *version);
+extern void util_get_uptime (time_t *total_seconds, int *days,
+ int *hours, int *minutes, int *seconds);
#endif /* WEECHAT_UTIL_H */
diff --git a/src/plugins/plugin-api.c b/src/plugins/plugin-api.c
index 280d830af..db0612de1 100644
--- a/src/plugins/plugin-api.c
+++ b/src/plugins/plugin-api.c
@@ -842,6 +842,52 @@ plugin_api_info_nick_color_name_cb (const void *pointer, void *data,
}
/*
+ * Returns WeeChat info "uptime".
+ */
+
+const char *
+plugin_api_info_uptime_cb (const void *pointer, void *data,
+ const char *info_name,
+ const char *arguments)
+{
+ static char value[32];
+ time_t total_seconds;
+ int days, hours, minutes, seconds;
+
+ /* make C compiler happy */
+ (void) pointer;
+ (void) data;
+ (void) info_name;
+
+ if (!arguments || !arguments[0])
+ {
+ /* return uptime with format: "days:hh:mm:ss" */
+ util_get_uptime (NULL, &days, &hours, &minutes, &seconds);
+ snprintf (value, sizeof (value), "%d:%02d:%02d:%02d",
+ days, hours, minutes, seconds);
+ return value;
+ }
+
+ if (strcmp (arguments, "days") == 0)
+ {
+ /* return the number of days */
+ util_get_uptime (NULL, &days, NULL, NULL, NULL);
+ snprintf (value, sizeof (value), "%d", days);
+ return value;
+ }
+
+ if (strcmp (arguments, "seconds") == 0)
+ {
+ /* return the number of seconds */
+ util_get_uptime (&total_seconds, NULL, NULL, NULL, NULL);
+ snprintf (value, sizeof (value), "%ld", total_seconds);
+ return value;
+ }
+
+ return NULL;
+}
+
+/*
* Returns WeeChat infolist "bar".
*
* Note: result must be freed after use with function weechat_infolist_free().
@@ -1922,6 +1968,11 @@ plugin_api_init ()
N_("get nick color name"),
N_("nickname"),
&plugin_api_info_nick_color_name_cb, NULL, NULL);
+ hook_info (NULL, "uptime",
+ N_("WeeChat uptime (format: \"days:hh:mm:ss\")"),
+ N_("\"days\" (number of days) or \"seconds\" (number of "
+ "seconds) (optional)"),
+ &plugin_api_info_uptime_cb, NULL, NULL);
/* WeeChat core infolist hooks */
hook_infolist (NULL, "bar",