lsf: add --time-format flag

Before this change, lsf's time format was hard-coded to "2006-01-02 15:04:05",
regardless of the Fs's precision. After this change, a new optional
--time-format flag is added to allow customizing the format (the default is
unchanged).

Examples:
	rclone lsf remote:path --format pt --time-format 'Jan 2, 2006 at 3:04pm (MST)'
	rclone lsf remote:path --format pt --time-format '2006-01-02 15:04:05.000000000'
	rclone lsf remote:path --format pt --time-format '2006-01-02T15:04:05.999999999Z07:00'
	rclone lsf remote:path --format pt --time-format RFC3339
	rclone lsf remote:path --format pt --time-format DateOnly
	rclone lsf remote:path --format pt --time-format max

--time-format max will automatically truncate '2006-01-02 15:04:05.000000000'
to the maximum precision supported by the remote.
This commit is contained in:
nielash
2023-12-07 19:29:55 -05:00
parent b06935a12e
commit 66929416d4
4 changed files with 183 additions and 15 deletions

View File

@@ -1240,7 +1240,7 @@ func TestListFormat(t *testing.T) {
assert.Equal(t, "a:::b", list.Format(item1))
list.SetOutput(nil)
list.AddModTime()
list.AddModTime("")
assert.Equal(t, t1.Local().Format("2006-01-02 15:04:05"), list.Format(item0))
list.SetOutput(nil)
@@ -1272,7 +1272,7 @@ func TestListFormat(t *testing.T) {
assert.Equal(t, "1", list.Format(item0))
list.AddPath()
list.AddModTime()
list.AddModTime("")
list.SetDirSlash(true)
list.SetSeparator("__SEP__")
assert.Equal(t, "1__SEP__a__SEP__"+t1.Local().Format("2006-01-02 15:04:05"), list.Format(item0))
@@ -1295,7 +1295,7 @@ func TestListFormat(t *testing.T) {
list.SetCSV(true)
list.AddSize()
list.AddPath()
list.AddModTime()
list.AddModTime("")
list.SetDirSlash(true)
assert.Equal(t, "1|a|"+t1.Local().Format("2006-01-02 15:04:05"), list.Format(item0))
assert.Equal(t, "-1|subdir/|"+t2.Local().Format("2006-01-02 15:04:05"), list.Format(item1))