Source File
filetime.go
Belonging Package
github.com/jcmturner/rpc/v2/mstypes
// Package mstypes implements representations of Microsoft types
package mstypes
import (
)
/*
FILETIME is a windows data structure.
Ref: https://msdn.microsoft.com/en-us/library/windows/desktop/ms724284%28v=vs.85%29.aspx
It contains two parts that are 32bit integers:
dwLowDateTime
dwHighDateTime
We need to combine these two into one 64bit integer.
This gives the number of 100 nano second period from January 1, 1601, Coordinated Universal Time (UTC)
*/
const unixEpochDiff = 116444736000000000
// FileTime implements the Microsoft FILETIME type https://msdn.microsoft.com/en-us/library/cc230324.aspx
type FileTime struct {
LowDateTime uint32
HighDateTime uint32
}
// Time return a golang Time type from the FileTime
func ( FileTime) () time.Time {
:= (.MSEpoch() - unixEpochDiff) * 100
return time.Unix(0, int64()).UTC()
}
// MSEpoch returns the FileTime as a Microsoft epoch, the number of 100 nano second periods elapsed from January 1, 1601 UTC.
func ( FileTime) () int64 {
return (int64(.HighDateTime) << 32) + int64(.LowDateTime)
}
// Unix returns the FileTime as a Unix time, the number of seconds elapsed since January 1, 1970 UTC.
func ( FileTime) () int64 {
return (.MSEpoch() - unixEpochDiff) / 10000000
}
// GetFileTime returns a FileTime type from the provided Golang Time type.
func ( time.Time) FileTime {
:= .UnixNano()
:= ( / 100) + unixEpochDiff
:= >> 32
:= - ( << 32)
return FileTime{
LowDateTime: uint32(),
HighDateTime: uint32(),
}
}
![]() |
The pages are generated with Golds v0.6.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |