Module: check_mk
Branch: master
Commit: 6ca251e0d43e95e815463e90f07ef50ebc9dbcfc
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6ca251e0d43e95…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Jun 7 15:09:39 2016 +0200
Start experimental lib module cmk.render
---
lib/{fmt.py => render.py} | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/lib/fmt.py b/lib/render.py
similarity index 69%
rename from lib/fmt.py
rename to lib/render.py
index adfafd8..2f31f7b 100644
--- a/lib/fmt.py
+++ b/lib/render.py
@@ -23,3 +23,24 @@
# License along with GNU Make; see the file COPYING. If not, write
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
+
+"""This module contains functions that transform Python values into
+text representations optimized for human beings - with optional localization.
+The resulting strings are not ment to be parsed into values again later. They
+are just for optical output purposes."""
+
+# THIS IS STILL EXPERIMENTAL
+
+import time
+
+# TODO: Clean this up one day by using the way recommended by gettext.
+# (See
https://docs.python.org/2/library/gettext.html). For this we
+# need the path to the locale files here.
+try:
+ _
+except NameError:
+ _ = lambda x: x # Fake i18n when not available
+
+
+def date(timestamp):
+ return time.strftime("%Y-%m-%d", time.localtime(timestamp))