Lol, this is unexpected and sad 

Installed "file-attributes" library to retrieve ctime from files and got "Not implemented"

#CommonLisp #programming

BTW, SBCLs "(sb-posix:stat-ctime (sb-posix:stat filename))" somehow returns wrong ctime — I got 1956 as a file creation year, while IRL it is equal to 2026 

#CommonLisp #SBCL

@evgandr How are you interpreting the result of ctime? It wouldn't be compatible with lisp universal times which have a different epoch. You'll need to adjust accordingly or use something that's aware of the unix epoch. The local-time package probably has something useful.

@davetenny Whoops, somehow I missed the sentence about difference between Common Lisp universal time and Unix universal time in the book . Thank you for pointing me on it!

Yep, I was trying to take the Unix universal time and convert it with function for Common Lisp universal time . The "local-time" library solved the issue:

* (local-time:unix-to-timestamp (sb-posix:stat-mtime (sb-posix:stat "./test2.jpg")))
  2025-08-16T17:28:28.000000+03:00

CC ⁨@Ardubal

@evgandr That's exactly the difference between the zero of Lisp's »Universal Time« and the zero of the Unix Epoch. I guess if you report this, it might get fixed overnight.

Edit: No, wait. stat-ctime gives you the number of seconds exactly as written in the file data, i. e. in Unix time. You probably called decode-universal-time yourself on that, which is wrong. You probably want the library "local-time" and its function "unix-to-timestamp".

@evgandr sb-posix:stat returns the linux structure, not universal-time.

You need to convert from posix time:

$ F=$(mktemp /tmp/sbcl-ctime.XXXXXX)
$ stat --format=%w $F
2026-03-05 22:18:28.153222304 +0100
$ sbcl \
--noinform \
--eval '(asdf:load-system "local-time")' \
--eval "(format t \"~A~%\" (local-time:unix-to-timestamp (sb-posix:stat-ctime (sb-posix:stat \"$F\"))))" \
--quit
2026-03-05T22:18:28.000000+01:00

EDIT: Didn't notice others had answered the same already.