From a0e89499b7a01724b8a2806805d8432e30e4aace Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sat, 9 Feb 2013 21:07:25 +0100 Subject: [PATCH] bin/calc: Add function to convert seconds to date. --- bin/calc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/bin/calc b/bin/calc index 6a40543..c364119 100755 --- a/bin/calc +++ b/bin/calc @@ -1,6 +1,6 @@ #!/bin/sh -# Copyright (C) 2011-2012 Simon Ruderich +# Copyright (C) 2011-2013 Simon Ruderich # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,7 +16,10 @@ # along with this program. If not, see . -exec python -i -c 'from math import *; +exec python -i -c ' + +# Math functions. +from math import * def ld(x): return log(x)/log(2) @@ -24,6 +27,15 @@ def ld(x): def binom(n,k): return reduce(lambda a,b: a*(n-b)/(b+1),xrange(k),1) + +# Time/Date functions. +import time + +# Convert time in seconds since epoch to readable string. +def stime(seconds): + print time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(seconds)) + + print "Welcome to the ultimate calculator."' # vim: ft=python -- 2.44.1