mirror of
https://github.com/samuelncui/yatm.git
synced 2026-11-08 04:18:03 +00:00
Unify file queries and Scan execution, retain indexed Identical results, improve Job and Preview workflows, and verify release packaging.
20 lines
527 B
Go
20 lines
527 B
Go
package dataformat
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
// Nanoseconds converts a source instant to the persisted signed Unix nanosecond format.
|
|
// A missing source time keeps the established zero sentinel instead of overflowing UnixNano.
|
|
func Nanoseconds(value time.Time) (int64, error) {
|
|
if value.IsZero() {
|
|
return 0, nil
|
|
}
|
|
stamp := value.UnixNano()
|
|
if !time.Unix(0, stamp).Equal(value) {
|
|
return 0, fmt.Errorf("timestamp %s is outside the signed Unix nanosecond range", value.Format(time.RFC3339Nano))
|
|
}
|
|
return stamp, nil
|
|
}
|