2 # Test --time-style in programs like 'ls'.
4 # Copyright (C) 2016-2024 Free Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <https://www.gnu.org/licenses/>.
19 .
"${srcdir=.}/tests/init.sh"; path_prepend_ .
/src
24 echo hello
>a || framework_failure_
26 # The tests assume this is an old timestamp in northern hemisphere summer.
27 TZ
=UTC0
touch -d '1970-07-08 09:10:11' a || framework_failure_
29 for tz
in UTC0 PST8 PST8PDT
,M3.2
.0,M11.1
.0 XXXYYY-12
:30; do
30 for style
in full-iso long-iso iso locale
'+%Y-%m-%d %H:%M:%S %z (%Z)' \
32 test "$style" = locale ||
33 TZ
=$tz LC_ALL
=C du
--time --time-style="$style" a
>>duout
2>>err || fail
=1
34 TZ
=$tz LC_ALL
=C
ls -no --time-style="$style" a
>>lsout
2>>err || fail
=1
36 (+*) TZ
=$tz LC_ALL
=C
pr -D"$style" a
>>prout
2>>err || fail
=1 ;;
41 sed 's/[^ ]* //' duout
>dued || framework_failure_
42 sed 's/[^ ]* *[^ ]* *[^ ]* *[^ ]* *//' lsout
>lsed || framework_failure_
43 sed '/^$/d' prout
>pred || framework_failure_
45 cat <<\EOF
> duexp || framework_failure_
46 1970-07-08 09:10:11.000000000 +0000 a
49 1970-07-08 09:10:11 +0000 (UTC
) a
51 1970-07-08 01:10:11.000000000 -0800 a
54 1970-07-08 01:10:11 -0800 (PST
) a
56 1970-07-08 02:10:11.000000000 -0700 a
59 1970-07-08 02:10:11 -0700 (PDT
) a
61 1970-07-08 21:40:11.000000000 +1230 a
64 1970-07-08 21:40:11 +1230 (XXXYYY
) a
68 cat <<\EOF
> lsexp || framework_failure_
69 1970-07-08 09:10:11.000000000 +0000 a
73 1970-07-08 09:10:11 +0000 (UTC
) a
75 1970-07-08 01:10:11.000000000 -0800 a
79 1970-07-08 01:10:11 -0800 (PST
) a
81 1970-07-08 02:10:11.000000000 -0700 a
85 1970-07-08 02:10:11 -0700 (PDT
) a
87 1970-07-08 21:40:11.000000000 +1230 a
91 1970-07-08 21:40:11 +1230 (XXXYYY
) a
95 cat <<\EOF
> prexp || framework_failure_
96 +1970-07-08 09:10:11 +0000 (UTC
) a Page
1
100 +1970-07-08 01:10:11 -0800 (PST
) a Page
1
104 +1970-07-08 02:10:11 -0700 (PDT
) a Page
1
108 +1970-07-08 21:40:11 +1230 (XXXYYY
) a Page
1
114 compare duexp dued || fail
=1
115 compare lsexp lsed || fail
=1
116 compare prexp pred || fail
=1
117 compare
/dev
/null err || fail
=1