Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Human readable datediff: "2 days ago" #154

Open
minfrin opened this issue Aug 22, 2023 · 1 comment
Open

Human readable datediff: "2 days ago" #154

minfrin opened this issue Aug 22, 2023 · 1 comment

Comments

@minfrin
Copy link

minfrin commented Aug 22, 2023

Is there a way to show human readable date differences?

Most specifically, given the expiry date of a certificate, I can get raw output of number of days until expiry or after expiry, positive or negative.

Is there a way to provide separate formats for positive results (eg "Expires in $d days"), exact results (eg "Expires today), and negative results (eg "Expired 2 days ago")?

@hroptatyr
Copy link
Owner

Hi,
no there is not. Can you maybe use awk to do what you desire?

$ echo 4 | awk '$0 = $1 > 0 ? "Expires in "$1" days" : $1 < 0 ? "Expired " ""-$1" days ago" : "Expires today"'
Expires in 4 days

$ echo -4  | awk '$0 = $1 > 0 ? "Expires in "$1" days" : $1 < 0 ? "Expired " ""-$1" days ago" : "Expires today"'
Expired 4 days ago

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants