busybox icon indicating copy to clipboard operation
busybox copied to clipboard

Allow 'touch' command to manage full precision timestamps

Open Rikk opened this issue 7 years ago • 4 comments

Hello @meefik (Sorry if this should have been sent to the original BusyBox author, I just don't know how to contact him...)

The 'touch' command in BusyBox seems not able to handle full precision timestamps (with micro/nano seconds). For example, touch -d "2015-01-01 01:01:01.123456789" File currently returns "touch: invalid date '...'". Also, the -r parameter does copy timestamps up to seconds precision (2015-01-01 01:01:01.000000000).

If anything can be done, many thanks.

Rikk avatar Feb 18 '18 07:02 Rikk

Use date format without milliseconds:

busybox touch -d "2015-01-01 01:01:01" /data/local/myfile
busybox ls -l /data/local/myfile                                          
-rw-rw-rw- root     root            0 2015-01-01 01:01 myfile

meefik avatar Feb 18 '18 09:02 meefik

Yes, I know it works, but I wanted to use full precision stamps. Can't it supported by BusyBox? More precisely, I found that in the original source at date.c file some comments indicate that touch would support that high-precision timestamp format behind some compilation flags. But I'm not familiar with BusyBox source at all, therefore my question. Thanks for the prompt answer!

Rikk avatar Feb 18 '18 11:02 Rikk

Yes, nanoseconds is not supported in NDK and thus disabled CONFIG_FEATURE_DATE_NANO option https://github.com/meefik/busybox/blob/master/contrib/patches-1.27.2/android_ndk_defconfig#L206

meefik avatar Feb 18 '18 11:02 meefik

So, will it fail to compile if you set CONFIG_FEATURE_DATE_NANO=y? Or can't set it manually?

On a side subject, what patch do you use to make ls --ful-time command display the proper timezone (eg. +0200) instead of UTC (+0000) when listing files? The Busybox built by other persons always convert the timezone to UTC (display +0000).

Btw, is your edition of 1.28.1 coming soon? :D

Rikk avatar Feb 22 '18 03:02 Rikk