Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File::Stat: return local time for atime, ctime and mtime #2477

wants to merge 1 commit into from


Copy link

stat = File.stat(__FILE__)
pp stat.atime
pp stat.mtime
pp stat.ctime


stat.atime = 2016-04-18 17:07:24 UTC
stat.mtime = 2016-04-18 17:07:19 UTC
stat.ctime = 2016-04-18 17:07:19 UTC


stat.atime = 2016-04-18 14:07:53 -0300
stat.mtime = 2016-04-18 14:07:19 -0300
stat.ctime = 2016-04-18 14:07:19 -0300

I think it's easier to work with local times regarding file information.

Copy link

jhass commented Apr 18, 2016

Given the DST issues and general unpolished timezone support yet, I'm not sure I'd like to +1 this just yet. Maybe put on hold until that's more solid? :)

Also what's the overhead of creating two Time objects (and a third when I do want the UTC time then)?

Copy link
Member Author

Hehe, sounds good :-)

Time is a struct wrapping an UInt64, so creating a Time is very cheap, no heap memory needed. But computing local time involves calling LibC.gettimeofday, but I guess that's fast too.

Copy link

I rebased this patch on 0.21.1 and it works as specified.

Since this was opened, #2481 has shipped, which added more Timezone-aware behaviors. also reports a TZ-aware value like so: 2017-03-17 21:01:37 -0400, so it seems like some degree of TZ-awareness is shipped?

Copy link

Time only handles UTC and Local. I have some unpublished code to make Time use 128bits and have nanosecond precision and timezone offset, but it's incomplete.

@asterite asterite closed this May 24, 2017
@asterite asterite deleted the feature/file_stat_local_time branch April 27, 2018 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

Successfully merging this pull request may close these issues.

None yet

4 participants