85a2705c22b08785fe1ba68538412d7ad5a8d7f7
[platform/upstream/bash.git] / tests / printf3.sub
1 LC_ALL=C
2 LANG=C
3
4 SHELLSTART=$(date +%s)
5 SECS=1275250155
6 export TZ=EST5EDT
7
8 printf "%()T\n" $SECS
9 printf "%(abde)Z\n" -1
10
11 printf "%(%e-%b-%Y %T)T\n" $SECS
12
13 printf -v v1 "%(%e-%b-%Y %T)T\n" $(date +%s)
14 printf -v v2 "%(%e-%b-%Y %T)T\n" -1
15
16 case $v1 in
17 $v2)    ;;
18 *)      echo "current time and -1 possible mismatch|$v1|$v2|" >&2 ;;
19 esac
20 unset v1 v2
21
22 v1=$(date +%s)
23 printf -v v2 "%(%s)T" -1
24
25 case $v1 in
26 $v2)    ;;
27 *)      echo "current time mismatch:$v1|$v2|" >&2 ;;
28 esac
29 unset v1 v2
30
31 printf "%(%x %X)T\n" $(( $SECS - 3600 ))
32
33 printf -v v1 "%(%F %r)T\n" $SHELLSTART
34 printf -v v2 "%(%F %r)T\n" -2
35
36 case $v1 in
37 $v2)    ;;
38 *)      echo "shell start time and -2 possible mismatch|$v1|$v2|" >&2 ;;
39 esac
40 unset v1 v2
41
42 printf "current time: %(%F %r)T\n" $SECS
43
44 printf "epoch time: %(%F %r %z)T\n" 0
45 printf "random time: %(%F %r %z)T\n"  $SECS
46
47 printf "local time: %(%a %b %e %H:%M:%S %Z %Y)T\n" $SECS
48
49 # test fieldwidth, justification, precision
50 printf "%-40.50(%a %b %e %H:%M:%S %Z %Y)T date-style time\n" $SECS
51
52 # test fieldwidth, justification, precision, embedded parens
53 printf "%-40.50(%x (foo) %X)T date-style time\n" $SECS