variant_date_amd64.go 586 B

1234567891011121314151617181920
  1. // +build windows,amd64
  2. package ole
  3. import (
  4. "errors"
  5. "syscall"
  6. "time"
  7. "unsafe"
  8. )
  9. // GetVariantDate converts COM Variant Time value to Go time.Time.
  10. func GetVariantDate(value uint64) (time.Time, error) {
  11. var st syscall.Systemtime
  12. r, _, _ := procVariantTimeToSystemTime.Call(uintptr(value), uintptr(unsafe.Pointer(&st)))
  13. if r != 0 {
  14. 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
  15. }
  16. return time.Now(), errors.New("Could not convert to time, passing current time.")
  17. }