Skip to content

fs/operations: add support for unix and unixnano time formats #8726

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

dmotte
Copy link

@dmotte dmotte commented Aug 4, 2025

What is the purpose of this change?

First of all, thank you so much for this amazing project! 🙂 I found Rclone extremely useful and very well done.

In this very simple PR I'm adding support for two new time formats: unix and unixnano. The reason behind this is that sometimes I use the rclone lsf command like this:

$ rclone lsf -R --format=pst --time-format=RFC3339 myremote:/
myfiles/;-1;2025-08-04T13:00:00+02:00
myfiles/file01.txt;123;2025-08-04T13:10:00+02:00
myfiles/file02.txt;456;2025-08-04T13:20:00+02:00
myfiles/file03.txt;789;2025-08-04T13:30:00+02:00

to generate a sort of CSV-based "tree" of a directory (either local or remote) with file sizes and last modification times. But the output of such command is timezone-dependent (note the +02:00s). So, if I run the same command on one of my servers, which has a copy of the same folder but the system time zone set to UTC, I get this:

$ rclone lsf -R --format=pst --time-format=RFC3339 myremote:/
myfiles/;-1;2025-08-04T11:00:00Z
myfiles/file01.txt;123;2025-08-04T11:10:00Z
myfiles/file02.txt;456;2025-08-04T11:20:00Z
myfiles/file03.txt;789;2025-08-04T11:30:00Z

So, even if the content of the directory is exactly the same, I'm unable to programmatically compare the two outputs, e.g. using the diff command.

Since Unix timestamps are timezone-agnostic, with this PR I'm introducing the possibility to do this:

$ rclone lsf -R --format=pst --time-format=unix myremote:/
myfiles/;-1;1754305200
myfiles/file01.txt;123;1754305800
myfiles/file02.txt;456;1754306400
myfiles/file03.txt;789;1754307000

And:

$ rclone lsf -R --format=pst --time-format=unixnano myremote:/
myfiles/;-1;1754305200123456789
myfiles/file01.txt;123;1754305800123456789
myfiles/file02.txt;456;1754306400123456789
myfiles/file03.txt;789;1754307000123456789

I hope this is useful :) let me know what you think. Thanks in advance!

Was the change discussed in an issue or in the forum before?

I don't think so. I tried to search but couldn't find anything related :)

Checklist

  • I have read the contribution guidelines.
  • I have added tests for all changes in this PR if appropriate.
  • I have added documentation for the changes if appropriate.
  • All commit messages are in house style.
  • I'm done, this Pull Request is ready for review :-)

Copy link
Contributor

@albertony albertony left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. First of all you should revert changes in autogenerated files. These would have been flagged by our linter, if we had allowed the workflows to run.

@dmotte
Copy link
Author

dmotte commented Aug 10, 2025

@albertony thank you so much for the review! And sorry for the oversight. I reverted the changes to the autogenerated files in 4a67257. I hope it's OK now. Let me know :)

@dmotte dmotte requested a review from albertony August 10, 2025 12:12
@albertony
Copy link
Contributor

Great, lets run the workflows and see. 👍

@dmotte
Copy link
Author

dmotte commented Aug 11, 2025

Hey @albertony JFYI it seems like all the workflows passed 🙂

@albertony albertony requested review from ncw and removed request for albertony August 11, 2025 11:05
@albertony
Copy link
Contributor

Great. Looks good as far as I can tell, good job!

However; I'll leave the final review up to Nick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants