Skip to content

Instantly share code, notes, and snippets.

@mbbx6spp
Last active March 11, 2023 02:40
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbbx6spp/38cb62f2fc654a684bb55096a91a4e42 to your computer and use it in GitHub Desktop.
Save mbbx6spp/38cb62f2fc654a684bb55096a91a4e42 to your computer and use it in GitHub Desktop.
Only shows in UTC because timezones are bullshit and I needed to pick one. Sorry. It is what my servers use.
#!/usr/bin/env bash
main() {
local -ri mar_end=1583042400
local -ri today="$(date +"%s")"
local -r dow="$(date -u +"%a")"
local -r time="$(date -u +"%T")"
local -ri secs=86400
local -ri days_since="$(( ((${today} - ${mar_end}) / ${secs}) + 1 ))"
echo "${dow} ${days_since} March 2020 ${time} UTC"
}
set -euo pipefail
main
@mbbx6spp
Copy link
Author

Output looks like:

$ covidate
Sat 322 March 2020 21:21:20 UTC

@mbbx6spp
Copy link
Author

Fixed so it should run on macOS thanks to lambdagrrl on Twitter.

@cransom
Copy link

cransom commented Mar 2, 2021

date +%a gets you short day name, versus the case. available in both gnu and bsd date

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment