summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/time.sh18
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/time.sh b/lib/time.sh
index 23b88ad..cb89ca8 100644
--- a/lib/time.sh
+++ b/lib/time.sh
@@ -79,6 +79,21 @@ _ob_mktime()
return 0
}
+_ob_mon_to_m()
+{
+ local mon="${1}"
+ shift 1 || _ob_abort
+ local m=
+
+ case ${mon} in
+ Jan) m=1;; Feb) m=2;; Mar) m=3;; Apr) m=4;;
+ May) m=5;; Jun) m=6;; Jul) m=7;; Aug) m=8;;
+ Sep) m=9;; Oct) m=10;; Nov) m=11;; Dec) m=12;;
+ esac
+ printf '%d' ${m}
+ return 0
+}
+
## @brief Convert a date and time into seconds since the Epoch
## @details \fBob_rfc822_mktime\fP() converts date and time formatted according
## to RFCs 822, 2822, and 5322 into non-leap seconds elapsed since the
@@ -111,13 +126,14 @@ ob_rfc822_mktime()
read wday mday mon year time tz <<-EOF
${rfc822_tm}
EOF
+ mon=$(_ob_mon_to_m ${mon})
IFS=':' read hour min sec <<-EOF
${time}
EOF
tzsgn="${tz%%[0-9]*}"; tz=${tz#[+-]}; tz=${tz#0}; tz=${tz#0}
tzhour=$((${tz} / 100))
tzmin=$(( ${tz} % 100))
- _ob_mktime ${year} ${mon#0} ${mday#0} ${hour#0} ${min#0} ${sec#0} \
+ _ob_mktime ${year} ${mon} ${mday#0} ${hour#0} ${min#0} ${sec#0} \
$((${tzsgn}1 * (${tzhour} * 60 + ${tzmin}) * 60))
return 0
}