Skip to content

Instantly share code, notes, and snippets.

@lowks
Created March 21, 2014 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lowks/9684959 to your computer and use it in GitHub Desktop.
Save lowks/9684959 to your computer and use it in GitHub Desktop.
Getting mtime with Elixir
iex(12)> File.stat("/tmp")
{:ok,
File.Stat[size: 20480, type: :directory, access: :read_write,
atime: {{2014, 3, 21}, {19, 44, 1}}, mtime: {{2014, 3, 21}, {20, 15, 1}},
ctime: {{2014, 3, 21}, {20, 15, 1}}, mode: 17407, links: 219,
major_device: 64769, minor_device: 0, inode: 3670017, uid: 0, gid: 0]}
iex(13)> {h, t} = File.stat("/tmp")
{:ok,
File.Stat[size: 20480, type: :directory, access: :read_write,
atime: {{2014, 3, 21}, {20, 16, 32}}, mtime: {{2014, 3, 21}, {20, 16, 33}},
ctime: {{2014, 3, 21}, {20, 16, 33}}, mode: 17407, links: 219,
major_device: 64769, minor_device: 0, inode: 3670017, uid: 0, gid: 0]}
iex(14)> t
File.Stat[size: 20480, type: :directory, access: :read_write,
atime: {{2014, 3, 21}, {20, 16, 32}}, mtime: {{2014, 3, 21}, {20, 16, 33}},
ctime: {{2014, 3, 21}, {20, 16, 33}}, mode: 17407, links: 219,
major_device: 64769, minor_device: 0, inode: 3670017, uid: 0, gid: 0]
iex(15)> File.Stat.mtime
** (UndefinedFunctionError) undefined function: File.Stat.mtime/0
(elixir) File.Stat.mtime()
iex(15)> File.Stat.mtime(t)
{{2014, 3, 21}, {20, 16, 33}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment