gitee.com/quant1x/gox@v1.21.2/api/filestat.go (about)

     1  package api
     2  
     3  import (
     4  	"errors"
     5  	"time"
     6  )
     7  
     8  var (
     9  	ErrInvalidFileStat = errors.New("invalid file stat")
    10  )
    11  
    12  type FileStat struct {
    13  	CreationTime   time.Time
    14  	LastAccessTime time.Time
    15  	LastWriteTime  time.Time
    16  }
    17  
    18  // SecondToTime 把秒级的时间戳转为time格式
    19  func SecondToTime(sec int64) time.Time {
    20  	return time.Unix(sec, 0)
    21  }
    22  
    23  func NanosecondToTime(nanoseconds int64) time.Time {
    24  	seconds := int64(time.Second)
    25  	sec := nanoseconds / seconds
    26  	nsec := nanoseconds % seconds
    27  	return time.Unix(sec, nsec)
    28  }