Files
worker/app/models/bits.go
Gleb Tv 2c7a0236da feat: publish standalone worker
Separate worker packaging and service lifecycle from the control plane.
2026-07-13 17:55:14 +03:00

32 строки
710 B
Go

package models
import "time"
// BeginningOfDay provides functionality.
func BeginningOfDay(t time.Time) time.Time {
year, month, day := t.Date()
return time.Date(year, month, day, 0, 0, 0, 0, t.Location())
}
// SetBit provides functionality.
// https://stackoverflow.com/questions/23192262/how-would-you-set-and-clear-a-single-bit-in-go
// Sets the bit at pos in the integer n.
func SetBit(n int, pos uint) int {
n |= (1 << pos)
return n
}
// ClearBit provides functionality.
// Clears the bit at pos in n.
func ClearBit(n int, pos uint) int {
mask := ^(1 << pos)
n &= mask
return n
}
// HasBit provides functionality.
func HasBit(n int, pos uint) bool {
val := n & (1 << pos)
return (val > 0)
}