Bug 257075

Summary: touch(1) does not accept input from date(1) with -I to -d
Product: Base System Reporter: Michael Osipov <michael.osipov>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: New ---    
Severity: Affects Some People CC: michael.osipov
Priority: ---    
Version: 12.2-STABLE   
Hardware: Any   
OS: Any   

Description Michael Osipov 2021-07-09 08:23:03 UTC
Running on stable/12:4e2ae05c3

I am trying to set the mtime of a file in the future to trick make.

# ahead_of_time="$(date -v +2S -Iseconds)"
# echo $ahead_of_time
2021-07-09T10:17:08+02:00
# touch -d "$ahead_of_time" .
touch: out of range or illegal time specification: YYYY-MM-DDThh:mm:SS[.frac][tz]

Although tz is documented as:
                   tz      An optional letter Z indicating the time is in UTC.
                           Otherwise, the time is assumed to be in local time.
                           Local time is affected by the value of the TZ
                           environment variable.

It is confusing in many ways:
* I cannot reuse default values produced by tools from base
* tz is not a TZ, but rather Zulu only and should rather say in the pattern:
YYYY-MM-DDThh:mm:SS[.frac][Z]

A much better approach would be if -d would parse properly extended ISO 8601 format as spit out by date -I and documented as such -- accepting any offset.