diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2024-06-04 12:52:39 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2024-06-04 12:52:39 -0400 |
commit | c6bb003b8882e9a16941f5803d072ec1cb728318 (patch) | |
tree | 273d7b3de70212b75bf6c841c70142a00fec5d3c /tests/gnu/used.sh | |
parent | 3da7fe8b4f5d6a41152d81bbfbd30b0ab3a9da1c (diff) | |
download | bfs-c6bb003b8882e9a16941f5803d072ec1cb728318.tar.xz |
xtime: Add support for @epochseconds timestamps
Diffstat (limited to 'tests/gnu/used.sh')
-rw-r--r-- | tests/gnu/used.sh | 31 |
1 files changed, 6 insertions, 25 deletions
diff --git a/tests/gnu/used.sh b/tests/gnu/used.sh index 5e5d4e9..fe0a778 100644 --- a/tests/gnu/used.sh +++ b/tests/gnu/used.sh @@ -1,37 +1,18 @@ -iso8601() { - printf '%04d-%02d-%02dT%02d:%02d:%02d\n' "$@" -} - cd "$TEST" -now=$(date '+%Y-%m-%dT%H:%M:%S') - -# Parse the current date -[[ "$now" =~ ^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})$ ]] || fail -# Treat leading zeros as decimal, not octal -YYYY=$((10#${BASH_REMATCH[1]})) -MM=$((10#${BASH_REMATCH[2]})) -DD=$((10#${BASH_REMATCH[3]})) -hh=$((10#${BASH_REMATCH[4]})) -mm=$((10#${BASH_REMATCH[5]})) -ss=$((10#${BASH_REMATCH[6]})) +now=$(epoch_time) # -used is always false if atime < ctime -yesterday=$(iso8601 $YYYY $MM $((DD - 1)) $hh $mm $ss) -"$XTOUCH" -at "$yesterday" yesterday +"$XTOUCH" -at "@$((now - 60 * 60 * 24))" yesterday # -used rounds up -tomorrow=$(iso8601 $YYYY $MM $DD $((hh + 1)) $mm $ss) -"$XTOUCH" -at "$tomorrow" tomorrow +"$XTOUCH" -at "@$((now + 60 * 60))" tomorrow -dayafter=$(iso8601 $YYYY $MM $((DD + 1)) $((hh + 1)) $mm $ss) -"$XTOUCH" -at "$dayafter" dayafter +"$XTOUCH" -at "@$((now + 60 * 60 * 25))" dayafter -nextweek=$(iso8601 $YYYY $MM $((DD + 6)) $((hh + 1)) $mm $ss) -"$XTOUCH" -at "$nextweek" nextweek +"$XTOUCH" -at "@$((now + 60 * 60 * (24 * 6 + 1)))" nextweek -nextyear=$(iso8601 $((YYYY + 1)) $MM $DD $hh $mm $ss) -"$XTOUCH" -at "$nextyear" nextyear +"$XTOUCH" -at "@$((now + 60 * 60 * 24 * 365))" nextyear bfs_diff -mindepth 1 \ -a -used 1 -printf '-used 1: %p\n' \ |