#!/bin/sh # # myday - print a date ranging from 6 AM to 6 AM in the ISO 8601 format # # SPDX-FileCopyrightText: 2023 Daniel Kalak # SPDX-License-Identifier: GPL-3.0-or-later # # This script prints the current date in the ISO 8601 format. However, a # day is defined to go from 06:00 to 06:00. So on 2023-07-01T05:30, the # script still prints 2023-06-30. This is to ensure consistency if you # tend to work past midnight. # # You can optionally specify an offset. "+0" or "-0" is the current day, # "+1" is the day after the current day, and "-1" is the day before the # current day. The sign is obligatory. Offsets with more than 3 digits # are not accepted. # # The script returns 0 on success and 1 on bad usage. [ "$#" -gt 1 ] && exit 1 case "$1" in ''|[+-][0-9]|[+-][0-9][0-9]|[+-][0-9][0-9][0-9]) ;; *) exit 1 ;; esac date -I -d "6 hours ago ${1:-+0} day"