Skip to content
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

Implement -newerXY #307

Closed
sylvestre opened this issue Jan 29, 2024 · 3 comments · Fixed by #342
Closed

Implement -newerXY #307

sylvestre opened this issue Jan 29, 2024 · 3 comments · Fixed by #342

Comments

@sylvestre
Copy link
Contributor

The upstream manpage states:

-newerXY reference
          Compares the timestamp of the current file with reference.   The
          reference  argument  is  normally the name of a file (and one of
          its timestamps is used for the comparison) but it may also be  a
          string  describing  an  absolute time.  X and Y are placeholders
          for other letters, and these letters select which time belonging
          to how reference is used for the comparison.

          a   The access time of the file reference
          B   The birth time of the file reference
          c   The inode status change time of reference
          m   The modification time of the file reference
          t   reference is interpreted directly as a time
$ find . ! -newermt 'jan 01, 2000' -exec touch -d@1706517278 {} +   
Error: Unrecognized flag: '-newermt'
@hanbings
Copy link
Collaborator

hanbings commented Mar 27, 2024

hi, this issue looks like there hasn't been an update here for a long time, can I give it a try?

@cakebaker
Copy link
Contributor

@hanbings sure, go ahead :)

@hanbings
Copy link
Collaborator

Thanks.

Now find . ! -newermt 'jan 01, 2000' -exec touch -d@1706517278 {} + works, and -newerat and -newerct is also available.
-newerBt is available, but depends on whether the file system supports birthed time / created time.

Use the following command to better observe the results.

find . -newermt 'jan 01, 2000'
find . -newermt 'jan 01, 2000 00:00:00'

In order to parse this time string, I added a function parse_date_str_to_timestamps() that converts from string to timestamp, then created the corresponding Matcher and compared it with the timestamp of the target file to get the result. I will add relevant test code later.

Please forgive my code for not looking very good.

@cakebaker cakebaker linked a pull request Mar 27, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants