touch: implement -t TIME (needed for testsuite)

This changes date -d TIME format a bit, makes it more compatible

function                                             old     new   delta
parse_datestr                                        391     618    +227
touch_main                                           360     361      +1
packed_usage                                       26624   26615      -9

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko
2009-07-18 04:49:20 +02:00
parent 7aca89a7a3
commit 38dd8aa657
3 changed files with 91 additions and 20 deletions

View File

@@ -64,10 +64,14 @@ int touch_main(int argc UNUSED_PARAM, char **argv)
#if ENABLE_DESKTOP && ENABLE_LONG_OPTS
applet_long_options = touch_longopts;
#endif
opts = getopt32(argv, "c" IF_DESKTOP("r:d:")
/* -d and -t both set time. In coreutils,
* accepted data format differs a bit between -d and -t.
* We accept the same formats for both */
opts = getopt32(argv, "c" IF_DESKTOP("r:d:t:")
/*ignored:*/ "fma"
IF_DESKTOP(, &reference_file)
IF_DESKTOP(, &date_str)
IF_DESKTOP(, &date_str)
);
opts &= 1; /* only -c bit is left */