Skip to content

Conversation

@0000xFFFF
Copy link

@0000xFFFF 0000xFFFF commented Dec 3, 2025

(closes #1701)

  • before merging:
    • needs testing on windows (idk how to compile lol)
    • info-widget.cc needs to be finished, it's not populating (or just remove the file date-times from there idk, but it seems like it should be in the Technical section)

works:

  • sorting works
  • qt adding columns with right click works
  • gtk adding columns works

arch linux 6.17.9-arch1-1

…ing on win)

added new datetime type need to copare dates

compare datetime

using int64 for datetimes

added get set dt (datetime)

using time_t adding win support

fix tuple

to_filed_map match date

ignore build dir

ignore compile commands

defaults to -1

ignore .cache

remove debug print
@radioactiveman
Copy link
Member

It's always nice to see a pull request for a feature from the same person who requested it. Thanks for working on this. 👍

I agree it would be nice to show the dates in the technical section in the Qt info dialog. Formatted though would be better in my opinion. And yes, it is buggy right now. The value changes every time when reopening the dialog and can even show negative values.

The timestamps should also be persisted. After restarting Audacious they are gone (playlist column is empty) and you need to refresh the files manually.

The code changes look fine to me from a first glance. Things to consider:

  • Is dt common or should we just write out datetime for public API functions?
  • The enum values Created and Modified are ambiguous, especially for Playlist as seen in your PR for audacious-plugins:
Playlist::Created,        // created
Playlist::Modified,       // modified
  • When shown in the UI, the date format should follow the locale preferences.

@jlindgren90: Could you please review the changes as well? Especially since they affect the fundamentals of Audacious. Testing on Windows would of course be nice too. Thanks in advance.

@0000xFFFF
Copy link
Author

Yeah I called it set_dt, I was blindly following the neighboring function naming conventions (... set_str rather then set_string...) that is the only reason, I see how that would be ambiguous now, sorry... also what should the Created, Modified enums be called? maybe something like FileCreated, FileModified, yeah same thing happened, I kept it simple since there was a Path enum and not a FilePath or FileName...

I did see that playlists don't persist datetimes when you reopen, I'll take some time adding that when I learn how audacious saves them...

Also following locale preferences might be my biggest priority first.

Thanks for the review.

@radioactiveman
Copy link
Member

Reading more about creation dates, this seems to be more complicated than expected.
stat.st_ctime is not the creation date. It is the last time the file’s metadata was changed.

https://lwn.net/Articles/397442/
https://itsfoss.gitlab.io/post/how-to-find-out-file-creation-date-and-time-in-linux/
https://unix.stackexchange.com/questions/91197/how-can-get-the-creation-date-of-a-file

My impression is that we should not write custom and platform dependent code for this. Using GIO instead could be an option but a) it is not available yet in libaudcore
b) it requires a rather new version of GLib
https://docs.gtk.org/gio/method.FileInfo.get_creation_date_time.html

Let's wait for John's response and recommendations on this matter.

@jlindgren90
Copy link
Member

This looks like a good start, thanks. Some thoughts:

  • Even though 32-bit systems are rare now, I think we should still avoid time_t in libaudcore API and add tuple_get/set_int64 instead. It could be useful for other fields in future.
  • I don't mind platform-specific functions where it makes sense, e.g. I think it's okay to use statx to get creation time on Linux rather than adding a hard gio dependency. FreeBSD and macOS support would be nice-to-haves but I don't think we need to block the feature for them.
  • Let's please hide the platform specific stuff behind the existing VFS layer though. See vfs_stdio.cc.
  • The audpl plugin should be updated to read/write the new tuple fields. It should be straightforward.

@0000xFFFF
Copy link
Author

So keep the DateTime type or replace it with Int64... or have both that represent the same thing (int64_t)?
I'm not sure how I'll draw the date time int64 in qtui/playlist_model.cc without the DateTime type,
since if Tuple::Int64, like you said, could be used to represent something other than datetimes in the future.

I guess keep both?

EXPORT StringBuf int64_to_str(int64_t val)
{
StringBuf buf;
str_insert_int(buf, 0, val);
Copy link
Member

Choose a reason for hiding this comment

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

This will not work for values >= 2^31

return str_compare_encoded(get_basename(a), get_basename(b));
}

static int tuple_compare_datetime(const Tuple & a, const Tuple & b,
Copy link
Member

Choose a reason for hiding this comment

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

We could just make tuple_compare_int take int64 and avoid duplication

// cleanly replace existing tuple
new_tuple.set_state(Tuple::Valid);

int64_t mtime = 0, ctime = 0;
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be better to avoid using "ctime" naming to avoid confusion

if (mtime)
*mtime = st.st_mtime;
if (ctime)
*ctime = st.st_ctime;
Copy link
Member

Choose a reason for hiding this comment

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

This isn't creation time. For systems where we don't know how to get creation time, we should just return e.g. -1.

Copy link
Author

Choose a reason for hiding this comment

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

when i google "ctime on windows" it keeps popping up that it actually is creation time??
yeah... idk... Microsoft... -_-

duping functions for int64 from int,
we could replace them to accept int64,
but not sure if that breaks anything
@0000xFFFF 0000xFFFF force-pushed the master branch 2 times, most recently from 03925d0 to 9251b56 Compare December 13, 2025 02:03
@0000xFFFF
Copy link
Author

0000xFFFF commented Dec 14, 2025

I have no idea why but Song Info isn't updating at all for me when I change anything and recompile,
it still just shows the original dialog.
Still don't know how to populate that, might try again in the future (still need to study the codebase thoroughly).

That is only thing that is missing qt/gtk fields for date times, other than that I think everything is working properly?

Edit: also sort by ("Playlist -> Sort -> By *") is missing for Created/Modified fields
Edit2: ok i added that ^

tuple_compare_date calls get_int64,
we need to allow Int types to get/set Int64
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.

Optional sort column for File Created/Modified date and time

3 participants