Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
class method
File.birthtime
File.birthtime(file_name) → time
file.c
View on GitHub ↗
RUBY_FUNC_EXPORTED VALUE
rb_file_s_birthtime(VALUE klass, VALUE fname)
{
statx_data st;
if (rb_statx(fname, &st, STATX_BTIME) < 0) {
int e = errno;
FilePathValue(fname);
rb_syserr_fail_path(e, fname);
}
return statx_birthtime(&st, fname);
}
Returns the birth time for the named file.
file_name can be an IO object.
Example
File.birthtime("testfile") #=> Wed Apr 09 08:53:13 CDT 2003
If the platform doesn’t have birthtime, raises NotImplementedError.