1 # This program is free software: you can redistribute it and/or modify
2 # it under the terms of the GNU General Public License as published by
3 # the Free Software Foundation, either version 3 of the License, or
4 # (at your option) any later version.
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 # GNU General Public License for more details.
11 # You should have received a copy of the GNU General Public License
12 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 SHELLSTART=$(date +%s)
22 *s*) SHELLSTART=$EPOCHSECONDS ; DATESECS=false ;; # take a shot
27 printf "%(abde)Z\n" -1
29 printf "%(%e-%b-%Y %T)T\n" $SECS
31 printf -v v1 "%(%e-%b-%Y %T)T\n" $( $DATESECS && date +%s || echo $EPOCHSECONDS )
32 printf -v v2 "%(%e-%b-%Y %T)T\n" -1
36 *) echo "current time and -1 possible mismatch|$v1|$v2|" >&2 ;;
41 printf -v v2 "%(%s)T" -1
45 *) echo "current time mismatch:$v1|$v2|" >&2 ;;
49 printf "%(%x %X)T\n" $(( $SECS - 3600 ))
51 printf -v v1 "%(%F %r)T\n" $SHELLSTART
52 printf -v v2 "%(%F %r)T\n" -2
56 *) echo "shell start time and -2 possible mismatch|$v1|$v2|" >&2 ;;
60 printf "current time: %(%F %r)T\n" $SECS
62 printf "epoch time: %(%F %r %z)T\n" 0
63 printf "random time: %(%F %r %z)T\n" $SECS
65 printf "local time: %(%a %b %e %H:%M:%S %Z %Y)T\n" $SECS
67 # test fieldwidth, justification, precision
68 printf "%-40.50(%a %b %e %H:%M:%S %Z %Y)T date-style time\n" $SECS
70 # test fieldwidth, justification, precision, embedded parens
71 printf "%-40.50(%x (foo) %X)T date-style time\n" $SECS
73 # problem introduced in bush-4.2 patch 5
75 printf '%(%Y-%m-%d %H:%M:%S %Z)T\n' >/dev/null