Permalink
Browse files

add seconds_to_hm, which rounds to the nearest minute

  • Loading branch information...
1 parent 7c755b6 commit a0b283e009eeffbfc49257456fd68704088172e9 @falconindy committed Jul 2, 2010
Showing with 18 additions and 3 deletions.
  1. +18 −3 clockwerk
View
@@ -63,6 +63,7 @@ date_to_seconds() {
return seconds
}
+# prints HH MM SS
seconds_to_hms() {
local seconds=$1 hours=0 minutes=0
@@ -75,6 +76,22 @@ seconds_to_hms() {
echo $hours $minutes $seconds
}
+# prints HH MM rounded to nearest minute
+seconds_to_hm() {
+ local seconds=$1 hours=0 minutes=0
+
+ hours=$(( seconds / 3600 ))
+ seconds=$(( seconds - hours * 3600 ))
+
+ minutes=$(( seconds / 60 ))
+ seconds=$(( seconds - minutes * 60 ))
+
+ (( seconds >= 30 )) && (( ++minutes ))
+
+ echo $hours $minutes
+}
+
+
# return 0 on success
# return 1 on failure
initialize_db() {
@@ -160,7 +177,6 @@ job_modify() {
:
}
-
#################################
# category functions #
#################################
@@ -185,7 +201,7 @@ category_delete() {
}
category_list() {
- local sql="SELECT c_name, c_desc FROM category"
+ local sql="SELECT DISTINCT j_category FROM job"
while IFS=$'|' read c_name c_desc; do
printf "%-20s%-20s\n" "$c_name" "$c_desc"
@@ -265,7 +281,6 @@ do_status() {
fi
}
-
#############
# main loop #
#############

0 comments on commit a0b283e

Please sign in to comment.