@@ -1101,12 +1101,26 @@ static VALUE statx_birthtime(const rb_io_stat_data *st);
11011101
11021102/*
11031103 * call-seq:
1104- * stat.atime -> time
1105- *
1106- * Returns the last access time for this file as an object of class
1107- * Time.
1108- *
1109- * File.stat("testfile").atime #=> Wed Dec 31 18:00:00 CST 1969
1104+ * atime -> new_time
1105+ *
1106+ * Returns a new Time object containing the access time
1107+ * of the object represented by +self+
1108+ * at the time +self+ was created;
1109+ * see {Snapshot}[rdoc-ref:File::Stat@Snapshot]:
1110+ *
1111+ * filepath = 't.tmp'
1112+ * File.write(filepath, 'foo')
1113+ * file = File.new(filepath, 'w')
1114+ * stat = File::Stat.new(filepath)
1115+ * file.atime # => 2026-03-31 16:26:39.5913207 -0500
1116+ * stat.atime # => 2026-03-31 16:26:39.5913207 -0500
1117+ * File.write(filepath, 'bar')
1118+ * file.atime # => 2026-03-31 16:27:01.4981624 -0500 # Changed by access.
1119+ * stat.atime # => 2026-03-31 16:26:39.5913207 -0500 # Unchanged by access.
1120+ * stat = File::Stat.new(filepath)
1121+ * stat.atime # => 2026-03-31 16:27:01.4981624 -0500 # New access time.
1122+ * file.close
1123+ * File.delete(filepath)
11101124 *
11111125 */
11121126
@@ -2452,13 +2466,23 @@ rb_file_s_ftype(VALUE klass, VALUE fname)
24522466
24532467/*
24542468 * call-seq:
2455- * File.atime(file_name) -> time
2469+ * File.atime(object) -> new_time
24562470 *
2457- * Returns the last access time for the named file as a Time object.
2471+ * Returns a new Time object containing the time of the most recent
2472+ * access (read or write) to the object,
2473+ * which may be a string filepath or dirpath, or a File or Dir object:
24582474 *
2459- * _file_name_ can be an IO object.
2475+ * filepath = 't.tmp'
2476+ * File.exist?(filepath) # => false
2477+ * File.atime(filepath) # Raises Errno::ENOENT.
2478+ * File.write(filepath, 'foo')
2479+ * File.atime(filepath) # => 2026-03-31 16:39:37.9290772 -0500
2480+ * File.write(filepath, 'bar')
2481+ * File.atime(filepath) # => 2026-03-31 16:39:57.7710876 -0500
24602482 *
2461- * File.atime("testfile") #=> Wed Apr 09 08:51:48 CDT 2003
2483+ * File.atime('.') # => 2026-03-31 16:47:49.0970483 -0500
2484+ * File.atime(File.new('README.md')) # => 2026-03-31 11:15:27.8215934 -0500
2485+ * File.atime(Dir.new('.')) # => 2026-03-31 12:39:45.5910591 -0500
24622486 *
24632487 */
24642488
@@ -2477,12 +2501,20 @@ rb_file_s_atime(VALUE klass, VALUE fname)
24772501
24782502/*
24792503 * call-seq:
2480- * file.atime -> time
2481- *
2482- * Returns the last access time (a Time object) for <i>file</i>, or
2483- * epoch if <i>file</i> has not been accessed.
2484- *
2485- * File.new("testfile").atime #=> Wed Dec 31 18:00:00 CST 1969
2504+ * atime -> new_time
2505+ *
2506+ * Returns a new Time object containing the time of the most recent
2507+ * access (read or write) to the file represented by +self+:
2508+ *
2509+ * filepath = 't.tmp'
2510+ * file = File.new(filepath, 'a+')
2511+ * file.atime # => 2026-03-31 17:11:27.7285397 -0500
2512+ * file.write('foo')
2513+ * file.atime # => 2026-03-31 17:11:27.7285397 -0500 # Unchanged; not yet written.
2514+ * file.flush
2515+ * file.atime # => 2026-03-31 17:12:11.3408054 -0500 # Changed; now written.
2516+ * file.close
2517+ * File.delete(filename)
24862518 *
24872519 */
24882520
0 commit comments