// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT.

//go:build (freebsd && arm) || (freebsd && arm64) || (linux && arm) || (linux && arm64) || (linux && ppc64le) || (linux && riscv64) || (openbsd && arm64)

package sqlite3

import (
	"unsafe"

	"modernc.org/libc"
)

// C documentation
//
//	/*
//	** Compute the Hour, Minute, and Seconds from the julian day number.
//	*/
func _computeHMS(tls *libc.TLS, p uintptr) {
	var day_min, day_ms int32
	_, _ = day_min, day_ms /* milliseconds, minutes into the day */
	if (*TDateTime)(unsafe.Pointer(p)).FvalidHMS != 0 {
		return
	}
	_computeJD(tls, p)
	day_ms = int32(((*TDateTime)(unsafe.Pointer(p)).FiJD + libc.Int64FromInt32(43200000)) % libc.Int64FromInt32(86400000))
	(*TDateTime)(unsafe.Pointer(p)).Fs = float64(day_ms%libc.Int32FromInt32(60000)) / float64(1000)
	day_min = day_ms / int32(60000)
	(*TDateTime)(unsafe.Pointer(p)).Fm = day_min % int32(60)
	(*TDateTime)(unsafe.Pointer(p)).Fh = day_min / int32(60)
	libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 0, 0x1)
	(*TDateTime)(unsafe.Pointer(p)).FvalidHMS = uint8(1)
}

// C documentation
//
//	/*
//	** Set the time to the current time reported by the VFS.
//	**
//	** Return the number of errors.
//	*/
func _setDateTimeToCurrent(tls *libc.TLS, context uintptr, p uintptr) (r int32) {
	(*TDateTime)(unsafe.Pointer(p)).FiJD = _sqlite3StmtCurrentTime(tls, context)
	if (*TDateTime)(unsafe.Pointer(p)).FiJD > 0 {
		(*TDateTime)(unsafe.Pointer(p)).FvalidJD = uint8(1)
		libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(1), 3, 0x8)
		libc.SetBitFieldPtr8Uint32(p+44, libc.Uint32FromInt32(0), 4, 0x10)
		_clearYMD_HMS_TZ(tls, p)
		return 0
	} else {
		return int32(1)
	}
	return r
}
