[SM-Commit] GIT changes to master sorcery by Jaka Kranjc (4654522181441f5c550aaa82c37f01e024fd364f)

Jaka Kranjc scm at sourcemage.org
Wed Jun 25 16:34:14 EDT 2008


GIT changes to master sorcery by Jaka Kranjc <lynxlynxlynx at sourcemage.org>:

 ChangeLog                       |    3 +++
 usr/sbin/gaze                   |   25 +++++++++++++++----------
 var/lib/sorcery/modules/libtime |    5 ++++-
 3 files changed, 22 insertions(+), 11 deletions(-)

New commits:
commit 4654522181441f5c550aaa82c37f01e024fd364f
Author: Jaka Kranjc <lynxlynxlynx at sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx at sourcemage.org>

    libtime
    display the spell name in front of each timing in quiet mode

commit 0d2043a015940e83833048918fcc7981b41bdd1a
Author: Jaka Kranjc <lynxlynxlynx at sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx at sourcemage.org>

    gaze:
    made time use the new helpers, fixed (big) total display and changed
          the quiet output to print seconds

diff --git a/ChangeLog b/ChangeLog
index 383f08b..1a80f94 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,8 +3,11 @@
 	  fixed a comment with a new insight
 	  added weighted mean mode where the last version's timing counts 10 times
 	  added compute_all_cast_times for use in gaze and two helper functions
+	  display the spell name in front of each timing in quiet mode
 	* gaze: added gaze time which shows the casting time of spells
 	  added time --full, which prints all the casting times we can compute
+	  made time use the new helpers, fixed (big) total display and changed
+	  the quiet output to print seconds
 	* libsorcery: in verify_source print "failure" instead of the
 	  unusual "failed"
 
diff --git a/usr/sbin/gaze b/usr/sbin/gaze
index cb6acc2..03c7205 100755
--- a/usr/sbin/gaze
+++ b/usr/sbin/gaze
@@ -2060,24 +2060,29 @@ function gaze_time() {
 
     if [[ $GAZE_VERBOSE != 0 ]]; then
       message -n "Casting ${SPELL_COLOR}$spell$DEFAULT_COLOR took "
-      time=$(date -u -d "1970-01-01 $diff seconds" "+%-Hh %-Mm")
-      if [[ "$time" == "0h 0m" ]]; then
-        echo "less than a minute."
-      else
-        echo $time
-      fi
+      time=$(epoch_to_hm $diff)
+      fix_zero_time "$time"
     else
-      echo -n "$spell:"
-      date -u -d "1970-01-01 $diff seconds" "+%Hh %Mm"
+      echo "$spell:$diff"
     fi
   done
 
   if [[ -n $2 ]]; then
     message -n "${MESSAGE_COLOR}Total time:$DEFAULT_COLOR "
     if [[ $GAZE_VERBOSE != 0 ]]; then
-      date -u -d "1970-01-01 $sum seconds" "+%-Hh %-Mm"
+      # date can only print day of year starting with 1, so we can't use it,
+      # yet we have to display the number of days, since the total can be big
+      awk -v sum=$sum 'END {
+        days = int(sum/3600/24)
+        sum -= days * 3600 * 24
+        hours = int(sum/3600)
+        sum -= hours * 3600
+        minutes = int(sum/60)
+
+        print days "d " (hours == 24 ? 0 : hours) "h " (minutes == 60 ? 0 : minutes) "m "
+      }' /dev/null
     else
-      date -u -d "1970-01-01 $sum seconds" "+%Hh %Mm"
+      echo $sum
     fi
   fi
 }
diff --git a/var/lib/sorcery/modules/libtime b/var/lib/sorcery/modules/libtime
index f2a1980..0797888 100755
--- a/var/lib/sorcery/modules/libtime
+++ b/var/lib/sorcery/modules/libtime
@@ -91,10 +91,13 @@ function compute_all_cast_times() {
   [[ -z $times ]] && return 1
 
   if [[ $verbosity == 0 ]]; then
-    echo $spell
+    echo -n $spell:
     echo "$times" | tail -n 1
+    echo -n $spell:
     echo "$times" | compute_median
+    echo -n $spell:
     echo "$times" | compute_mean
+    echo -n $spell:
     echo "$times" | compute_weighted_mean last-cast $(private_installed_version $spell)
     echo
   else



More information about the SM-Commit mailing list