mirror of
https://github.com/coreutils/coreutils.git
synced 2026-10-28 09:44:34 +08:00
tests: date: check that weekdays are ignored when given an explicit date
* tests/date/date.pl: Add some test cases. * tests/date/date-debug.sh: Test the debug output for this case.
This commit is contained in:
1 parent
2db599e8b0
commit
6e812858bb
2 files changed
+39
No files matched your search
@@ -310,5 +310,24 @@ sed '2s/(Y-M-D) [0-9][0-9][0-9][0-9]-/(Y-M-D) XXXX-/' out10_t >> out10 \
|
||||
|| framework_failure_
|
||||
compare exp10 out10 || fail=1
|
||||
|
||||
# Test that the weekday is ignored when explicit dates are given.
|
||||
cat<<EOF>exp11
|
||||
date: parsed day part: Tue (day ordinal=0 number=2)
|
||||
date: parsed date part: (Y-M-D) 2026-07-22
|
||||
date: input timezone: TZ="UTC0" environment value or -u
|
||||
date: warning: using midnight as starting time: 00:00:00
|
||||
date: warning: day (Tue) ignored when explicit dates are given
|
||||
date: starting date/time: '(Y-M-D) 2026-07-22 00:00:00'
|
||||
date: '(Y-M-D) 2026-07-22 00:00:00' = 1784678400 epoch-seconds
|
||||
date: timezone: Universal Time
|
||||
date: final: 1784678400.000000000 (epoch-seconds)
|
||||
date: final: (Y-M-D) 2026-07-22 00:00:00 (UTC)
|
||||
date: final: (Y-M-D) 2026-07-22 00:00:00 (UTC+00)
|
||||
date: output format: '$d_t_fmt'
|
||||
Wed Jul 22 00:00:00 UTC 2026
|
||||
EOF
|
||||
|
||||
date -u --debug -d 'Tue, 2026-07-22' >out11 2>&1 || fail=1
|
||||
compare exp11 out11 || fail=1
|
||||
|
||||
Exit $fail
|
||||
@@ -466,6 +466,26 @@ push @Tests,
|
||||
{EXIT => 1},
|
||||
];
|
||||
|
||||
# Test that the weekday is ignored when explicit dates are given.
|
||||
# However, a invalid weekday will still result in an error.
|
||||
my @weekdays = ('Mond', 'Tuesd', 'Wedn', 'Thursd', 'Frid', 'Satu', 'Sund');
|
||||
my (@bad, @good);
|
||||
for my $i (1..$#weekdays + 1)
|
||||
{
|
||||
my $weekday = $weekdays[$i - 1];
|
||||
my $iso_date = "2026-07-" . ($weekday eq 'Wedn' ? '21' : '22');
|
||||
my $date = "$weekday, $iso_date";
|
||||
push @bad,
|
||||
["bad-weekday-explict-date$i", "-u -d '$date' +'%Y-%m-%d'",
|
||||
{ERR=>"date: invalid date '$date'\n"}, {EXIT=>1}];
|
||||
chop $weekday;
|
||||
my $date = "$weekday, $iso_date";
|
||||
push @good,
|
||||
["good-weekday-explict-date$i", "-u -d '$date' +'%Y-%m-%d'",
|
||||
{OUT=>"$iso_date"}];
|
||||
}
|
||||
push @Tests, @bad, @good;
|
||||
|
||||
# Repeat the cross-dst test, using Jan 1, 2005 and every interval from 1..364.
|
||||
foreach my $i (1..364)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user