End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
File#atime
file.atime → time
file.c
View on GitHub ↗
static VALUE
rb_file_atime(VALUE obj)
{
rb_io_t *fptr;
struct stat st;
GetOpenFile(obj, fptr);
if (fstat(fptr->fd, &st) == -1) {
rb_sys_fail_path(fptr->pathv);
}
return stat_atime(&st);
}
Returns the last access time (a Time object) for file, or epoch if file has not been accessed.
Example
File.new("testfile").atime #=> Wed Dec 31 18:00:00 CST 1969