Differences between version 2 and previous revision of KnowledgeBase/Scripts/epochdays.sh.
Other diffs: Previous Major Revision, Previous Author
Newer page: | version 2 | Last edited on Saturday, 10 April 2010 20:06:50 | by CyberLeo | Revert |
Older page: | version 1 | Last edited on Saturday, 10 April 2010 17:41:33 | by CyberLeo | Revert |
@@ -16,9 +16,9 @@
echo $(( $(date -j -f %Y-%m-%d "%{1}" +%s) / 86400 ))
}
epochdays_to_date() {
[ "${1}" ] || return 1
- adte
-jr $(( ${1} * 86400 )) +%Y-%m-%d
+ date
-jr $(( ${1} * 86400 )) +%Y-%m-%d
}
;;
esac
</code>
version 2
case "$(uname -s)" in Linux) date_to_epochdays() { [ "${1}" ] || return 1 echo $(( $(date +%s -d "${1}") / 86400 )) } epochdays_to_date() { [ "${1}" ] || return 1 date -d "1970-01-01 $(( ${1} * 86400 )) sec" +%Y-%m-%d } ;; FreeBSD) date_to_epochdays() { [ "${1}" ] || return 1 echo $(( $(date -j -f %Y-%m-%d "%{1}" +%s) / 86400 )) } epochdays_to_date() { [ "${1}" ] || return 1 date -jr $(( ${1} * 86400 )) +%Y-%m-%d } ;; esac