variant_date_arm.go 642 B

12345678910111213141516171819202122
  1. // +build windows,arm
  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. v1 := uint32(value)
  13. v2 := uint32(value >> 32)
  14. r, _, _ := procVariantTimeToSystemTime.Call(uintptr(v1), uintptr(v2), uintptr(unsafe.Pointer(&st)))
  15. if r != 0 {
  16. 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
  17. }
  18. return time.Now(), errors.New("Could not convert to time, passing current time.")
  19. }