GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - djherbis/times: #golang file times (atime, mtime, ctime, btime)

BranchesTags
Open more actions menu

Latest commit

 

History

116 Commits
116 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
example
example
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
bench_test.go
bench_test.go
 
 
ctime_windows.go
ctime_windows.go
 
 
go.mod
go.mod
 
 
go.sum
go.sum
 
 
js.cover.dockerfile
js.cover.dockerfile
 
 
js.cover.sh
js.cover.sh
 
 
linux.cover.dockerfile
linux.cover.dockerfile
 
 
linux.cover.sh
linux.cover.sh
 
 
times.go
times.go
 
 
times_aix.go
times_aix.go
 
 
times_darwin.go
times_darwin.go
 
 
times_dragonfly.go
times_dragonfly.go
 
 
times_freebsd.go
times_freebsd.go
 
 
times_js.go
times_js.go
 
 
times_linux.go
times_linux.go
 
 
times_linux_test.go
times_linux_test.go
 
 
times_nacl.go
times_nacl.go
 
 
times_netbsd.go
times_netbsd.go
 
 
times_openbsd.go
times_openbsd.go
 
 
times_plan9.go
times_plan9.go
 
 
times_solaris.go
times_solaris.go
 
 
times_test.go
times_test.go
 
 
times_wasip1.go
times_wasip1.go
 
 
times_windows.go
times_windows.go
 
 
times_windows_test.go
times_windows_test.go
 
 
use_generic_stat.go
use_generic_stat.go
 
 
util_test.go
util_test.go
 
 

Repository files navigation

times

GoDoc Release Software License go test Coverage Status Go Report Card Sourcegraph

Usage

File Times for #golang

Go has a hidden time functions for most platforms, this repo makes them accessible.

package main

import (
  "log"

  "github.com/djherbis/times"
)

func main() {
  t, err := times.Stat("myfile")
  if err != nil {
    log.Fatal(err.Error())
  }

  log.Println(t.AccessTime())
  log.Println(t.ModTime())

  if t.HasChangeTime() {
    log.Println(t.ChangeTime())
  }

  if t.HasBirthTime() {
    log.Println(t.BirthTime())
  }
}

Supported Times

windows linux solaris dragonfly nacl freebsd darwin netbsd openbsd plan9 js aix
atime ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓
mtime ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓
ctime ✓* ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓
btime ✓ ✓* ✓ ✓ ✓
  • Linux btime requires kernel 4.11 and filesystem support, so HasBirthTime = false. Use Timespec.HasBirthTime() to check if file has birth time. Get(FileInfo) never returns btime.
  • Windows XP does not have ChangeTime so HasChangeTime = false, however Vista onward does have ChangeTime so Timespec.HasChangeTime() will only return false on those platforms when the syscall used to obtain them fails.
  • Also note, Get(FileInfo) will now only return values available in FileInfo.Sys(), this means Stat() is required to get ChangeTime on Windows

Installation

go get -u github.com/djherbis/times

About

#golang file times (atime, mtime, ctime, btime)

Resources

Readme
MIT license
Activity

Stars

281 stars

Watchers

5 watching

Forks

37 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.