datefmt

format unix timestamps over stdin
git clone git://jb55.com/datefmt
Log | Files | Refs | README | LICENSE

commit fc8266c51cf956d1e27bc205d47f01fed24ef06b
parent dbea1f165de78af9ba5ed640944e06bce4bbc832
Author: William Casarin <jb55@jb55.com>
Date:   Thu, 17 Nov 2022 10:13:55 -0800

changelog, make pushing new version easier

Diffstat:
M.gitignore | 3+++
MCHANGELOG.md | 1+
MMakefile | 18+++++++++++++++---
Mdist/SHA256SUMS.txt | 2+-
Mdist/SHA256SUMS.txt.asc | 8++++----
Adoc/datefmt.gmi | 68++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 92 insertions(+), 8 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -6,3 +6,6 @@ /dist/*.tar.gz /.envrc /default.nix +/version +/doc/datefmt.html +/doc/datefmt.md diff --git a/CHANGELOG.md b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 0.2.2 +- Added `--relative` date formatting - Added `DEFAULT_DATEFMT` env var to change default format string ## 0.2.1 diff --git a/Makefile b/Makefile @@ -4,18 +4,30 @@ PREFIX ?= /usr all: datefmt docs -docs: doc/datefmt.1 README +docs: doc/datefmt.html doc/datefmt.1 README README: datefmt.c ./datefmt --help > $@ -dist: +dist: docs version @mkdir -p dist - @grep '^#define VERSION' datefmt.c | sed -En 's,.*"([^"]+)".*,\1,p' | xargs -I{} git archive HEAD --format tar.gz --prefix datefmt-{}/ -o dist/datefmt-{}.tar.gz + git archive HEAD --format tar.gz --prefix datefmt-$(shell cat version)/ -o dist/datefmt-$(shell cat version).tar.gz @ls -dt dist/* | head -n1 | xargs echo "tgz " cd dist;\ sha256sum *.tar.gz > SHA256SUMS.txt;\ gpg -u 0x8A478B64FFE30F1095A8736BF5F27EFD1B38DABB --sign --armor --detach-sig --output SHA256SUMS.txt.asc SHA256SUMS.txt + rsync -avzP dist/ charon:/www/cdn.jb55.com/tarballs/datefmt/ + scp doc/datefmt.html charon:public/datefmt/index.html + scp CHANGELOG.md charon:/www/cdn.jb55.com/tarballs/datefmt/CHANGELOG.txt + +version: datefmt.c + grep '^#define VERSION' $< | sed -En 's,.*"([^"]+)".*,\1,p' > $@ + +doc/datefmt.md: doc/datefmt.gmi version + <$< gmi2md | sed "s,@VERSION,$(shell cat version),g" > $@ + +doc/datefmt.html: doc/datefmt.md + pandoc -s $< -o $@ datefmt: datefmt.c $(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) diff --git a/dist/SHA256SUMS.txt b/dist/SHA256SUMS.txt @@ -1,3 +1,3 @@ 5d5e765380afe39eb39d48f752aed748b57dfd843a4947b2a6d18ab9b5e68092 datefmt-0.2.1.tar.gz -b32cb5f2513dc05972083f9b67391375e5d8db94c0a982bbe307bb8a7698bd75 datefmt-0.2.2.tar.gz +1e05bfbce19512601b9bc937a08c086be72882aeea997ecc7d3987ab1bfd9616 datefmt-0.2.2.tar.gz 3dab9cf8e58915d0880cb9f69856be041941f21009d0572644064b200606d65f datefmt-0.2.tar.gz diff --git a/dist/SHA256SUMS.txt.asc b/dist/SHA256SUMS.txt.asc @@ -1,7 +1,7 @@ -----BEGIN PGP SIGNATURE----- -iHUEABYKAB0WIQSKR4tk/+MPEJWoc2v18n79GzjauwUCY3Z0TgAKCRD18n79Gzja -u4Z3AQDg8nro3jBhwCksU7OuniYKSl40gVOiLQl3CUVITxtU2QD+K4Ml0pgH5p1M -244Ck20dCh5QPEWZi7/hUM2RQfoA8AU= -=A55f +iHUEABYKAB0WIQSKR4tk/+MPEJWoc2v18n79GzjauwUCY3Z5pgAKCRD18n79Gzja +u1tqAP92M8PLV1AdUUAGBIzRVxYk4OHWKh91tQWiSHOQ45PuGgEAkb5P5PPoLJek +4k5DteauMoJjjYXRlKes98VsZlKlagQ= +=QWgd -----END PGP SIGNATURE----- diff --git a/doc/datefmt.gmi b/doc/datefmt.gmi @@ -0,0 +1,68 @@ + +# datefmt + +datefmt is a simple C program that formats unix timestamps in text streams + +## Examples + +Let's say we have some logs that contain unix timestamps: + +``` +$ cat logs.txt + +EVENTS 1638499687 blahblah log1 +EVENTS 1638499717 blahblah log2 +``` + +We can pipe this log into datefmt to convert these timestamps into human-readable dates: + +``` +$ <logs.txt datefmt + +EVENTS 2021-12-02 18:48 blahblah log1 +EVENTS 2021-12-02 18:48 blahblah log2 +``` + +Of course you can customize the format as well: + +``` +$ <logs.txt datefmt "DATE:'%m-%d %R'" + +EVENTS DATE:'12-02 18:48' blahblah log1 +EVENTS DATE:'12-02 18:48' blahblah log2 +``` + + +It's as simple as that! It comes with some heuristics so that it doesn't parse timestamp outside of a reasonable range. + +## Download + +Tarballs are available here, please feel free to package this for your linux distribution of choice! + +=> http://cdn.jb55.com/tarballs/datefmt/CHANGELOG.txt Changelog + +=> http://cdn.jb55.com/tarballs/datefmt/datefmt-@VERSION.tar.gz Latest Version (@VERSION) + +=> http://cdn.jb55.com/tarballs/datefmt/SHA256SUMS.txt SHA256SUMS + +=> http://cdn.jb55.com/tarballs/datefmt/SHA256SUMS.txt.asc SHA256SUMS Signature + +=> https://jb55.com/pgp.txt My pgp key + +Download and verify: + +* `wget https://jb55.com/pgp.txt http://cdn.jb55.com/tarballs/datefmt/datefmt-@VERSION.tar.gz http://cdn.jb55.com/tarballs/datefmt/SHA256SUMS.txt http://cdn.jb55.com/tarballs/datefmt/SHA256SUMS.txt.asc` +* `gpg --import < pgp.txt` +* `sha256sum -c SHA256SUMS.txt` +* `gpg --verify SHA256SUMS.txt.asc` + +=> http://cdn.jb55.com/tarballs/datefmt Older versions + + +## Contributing + +Send patches to `jb55@jb55.com` + +=> http://git.jb55.com/datefmt Sources + +=> https://git-send-email.io/ How to send email patches