Created
January 28, 2021 02:15
-
-
Save justanotherdot/8b130ad303b7bec2ff7cc405db3fdbe1 to your computer and use it in GitHub Desktop.
Compare twwo dates.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
: {d1:=1} | |
: {d2:=2} | |
: {op:?"provide an operator for comparison"} | |
lhs=date -j -f "%F" "$d1" +%s 2>/dev/null | |
rhs=date -j -f "%F" "$d2" +%s 2>/dev/null | |
case $op in | |
"eq") | |
[ lhs -eq rhs ] ;; | |
"ge") | |
[ lhs -ge rhs ] ;; | |
"le") | |
[ lhs -le rhs ] ;; | |
"gt") | |
[ lhs -gt rhs ] ;; | |
"lt") | |
[ lhs -lt rhs ] ;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment