github.com/hspan/go-ole@v0.0.0/variant_date_386.go (about) 1 // +build windows,386 2 3 package ole 4 5 import ( 6 "errors" 7 "syscall" 8 "time" 9 "unsafe" 10 ) 11 12 // GetVariantDate converts COM Variant Time value to Go time.Time. 13 func GetVariantDate(value uint64) (time.Time, error) { 14 var st syscall.Systemtime 15 v1 := uint32(value) 16 v2 := uint32(value >> 32) 17 r, _, _ := procVariantTimeToSystemTime.Call(uintptr(v1), uintptr(v2), uintptr(unsafe.Pointer(&st))) 18 if r != 0 { 19 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 20 } 21 return time.Now(), errors.New("Could not convert to time, passing current time.") 22 }