summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authorS-H-GAMELINKS <gamelinks007@gmail.com>2021-08-23 21:24:31 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-08-24 09:23:07 +0900
commit4794a8a7cf4c9da00728e691b81dadb103383108 (patch)
treebf4cc0b12c8638bb07f36f4963301d6c6b60a5ff /file.c
parent70abda1ad4e9910d87266ed350f262d6ef894d65 (diff)
Add stat_time function
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4761
Diffstat (limited to 'file.c')
-rw-r--r--file.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/file.c b/file.c
index 41ebf863b6f..eb10c54c34d 100644
--- a/file.c
+++ b/file.c
@@ -886,12 +886,17 @@ stat_atimespec(const struct stat *st)
}
static VALUE
-stat_atime(const struct stat *st)
+stat_time(const struct timespec ts)
{
- struct timespec ts = stat_atimespec(st);
return rb_time_nano_new(ts.tv_sec, ts.tv_nsec);
}
+static VALUE
+stat_atime(const struct stat *st)
+{
+ return stat_time(stat_atimespec(st));
+}
+
static struct timespec
stat_mtimespec(const struct stat *st)
{
@@ -912,8 +917,7 @@ stat_mtimespec(const struct stat *st)
static VALUE
stat_mtime(const struct stat *st)
{
- struct timespec ts = stat_mtimespec(st);
- return rb_time_nano_new(ts.tv_sec, ts.tv_nsec);
+ return stat_time(stat_mtimespec(st));
}
static struct timespec
@@ -936,8 +940,7 @@ stat_ctimespec(const struct stat *st)
static VALUE
stat_ctime(const struct stat *st)
{
- struct timespec ts = stat_ctimespec(st);
- return rb_time_nano_new(ts.tv_sec, ts.tv_nsec);
+ return stat_time(stat_ctimespec(st));
}
#define HAVE_STAT_BIRTHTIME