]> git.ipfire.org Git - thirdparty/bash.git/blame - tests/printf3.sub
Bash-4.4 patch 19
[thirdparty/bash.git] / tests / printf3.sub
CommitLineData
495aee44
CR
1LC_ALL=C
2LANG=C
3
4SHELLSTART=$(date +%s)
5SECS=1275250155
6export TZ=EST5EDT
7
ac50fbac
CR
8case $SHELLSTART in
9*s*) SHELLSTART=$(perl -e 'print time') ; DATESECS=false ;; # take a shot
10*) DATESECS=true ;;
11esac
12
495aee44
CR
13printf "%()T\n" $SECS
14printf "%(abde)Z\n" -1
15
16printf "%(%e-%b-%Y %T)T\n" $SECS
17
ac50fbac 18printf -v v1 "%(%e-%b-%Y %T)T\n" $( $DATESECS && date +%s || perl -e 'print time')
495aee44
CR
19printf -v v2 "%(%e-%b-%Y %T)T\n" -1
20
21case $v1 in
22$v2) ;;
23*) echo "current time and -1 possible mismatch|$v1|$v2|" >&2 ;;
24esac
25unset v1 v2
26
27v1=$(date +%s)
28printf -v v2 "%(%s)T" -1
29
30case $v1 in
31$v2) ;;
32*) echo "current time mismatch:$v1|$v2|" >&2 ;;
33esac
34unset v1 v2
35
36printf "%(%x %X)T\n" $(( $SECS - 3600 ))
37
38printf -v v1 "%(%F %r)T\n" $SHELLSTART
39printf -v v2 "%(%F %r)T\n" -2
40
41case $v1 in
42$v2) ;;
43*) echo "shell start time and -2 possible mismatch|$v1|$v2|" >&2 ;;
44esac
45unset v1 v2
46
47printf "current time: %(%F %r)T\n" $SECS
48
49printf "epoch time: %(%F %r %z)T\n" 0
50printf "random time: %(%F %r %z)T\n" $SECS
51
52printf "local time: %(%a %b %e %H:%M:%S %Z %Y)T\n" $SECS
53
54# test fieldwidth, justification, precision
55printf "%-40.50(%a %b %e %H:%M:%S %Z %Y)T date-style time\n" $SECS
56
57# test fieldwidth, justification, precision, embedded parens
58printf "%-40.50(%x (foo) %X)T date-style time\n" $SECS
ac50fbac
CR
59
60# problem introduced in bash-4.2 patch 5
61unset TZ
62printf '%(%Y-%m-%d %H:%M:%S %Z)T\n' >/dev/null