github.com/go-ole/go-ole@v1.2.6/variant_date_arm64.go (about)

     1  //go:build windows && arm64
     2  // +build windows,arm64
     3  
     4  package ole
     5  
     6  import (
     7  	"errors"
     8  	"syscall"
     9  	"time"
    10  	"unsafe"
    11  )
    12  
    13  // GetVariantDate converts COM Variant Time value to Go time.Time.
    14  func GetVariantDate(value uint64) (time.Time, error) {
    15  	var st syscall.Systemtime
    16  	v1 := uint32(value)
    17  	v2 := uint32(value >> 32)
    18  	r, _, _ := procVariantTimeToSystemTime.Call(uintptr(v1), uintptr(v2), uintptr(unsafe.Pointer(&st)))
    19  	if r != 0 {
    20  		return time.Date(int(st.Year), time.Month(st.Month), int(st.Day), int(st.Hour), int(st.Minute), int(st.Second), int(st.Milliseconds/1000), time.UTC), nil
    21  	}
    22  	return time.Now(), errors.New("Could not convert to time, passing current time.")
    23  }