From 400dacdeb69bc13868a625fc2ce8b49b6acd5ae3 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Sat, 8 Aug 2015 13:39:01 -0500 Subject: Reject invalid dates in date(1). Humans get upset when date(1) lets mktime(3) work out what the 99th day of the 99th month would be rather than rejecting the invalid date. For the subtly wrong cases, rather than get into the leap year business, let's rely on localtime_r(3). --- tests/date.test | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 tests/date.test (limited to 'tests') diff --git a/tests/date.test b/tests/date.test new file mode 100644 index 00000000..d72e50cf --- /dev/null +++ b/tests/date.test @@ -0,0 +1,10 @@ +#!/bin/bash + +[ -f testing.sh ] && . testing.sh + +#testing "name" "command" "result" "infile" "stdin" + +# Accidentally given a Unix time, we should trivially reject that. +testing "date Unix time" "date 1438053157 2>&1" "date: bad date '1438053157'\n" "" "" +# But some invalid dates are more subtle, like Febuary 29th in a non-leap year. +testing "date Feb 29th" "date 022900001975 2>&1" "date: bad date -- cgit v1.2.3