diff --git a/_demo/ctime/time.go b/_demo/ctime/time.go new file mode 100644 index 00000000..e5a9ec56 --- /dev/null +++ b/_demo/ctime/time.go @@ -0,0 +1,12 @@ +package main + +import "github.com/goplus/llgo/c/time" + +func main() { + var tv time.Timespec + time.ClockGettime(time.CLOCK_REALTIME, &tv) + println("REALTIME sec:", tv.Sec, "nsec:", tv.Nsec) + + time.ClockGettime(time.CLOCK_MONOTONIC, &tv) + println("MONOTONIC sec:", tv.Sec, "nsec:", tv.Nsec) +} diff --git a/internal/lib/time/zoneinfo_read.go b/internal/lib/time/zoneinfo_read.go index c32d1a7c..82a2a8b1 100644 --- a/internal/lib/time/zoneinfo_read.go +++ b/internal/lib/time/zoneinfo_read.go @@ -320,7 +320,7 @@ func LoadLocationFromTZData(name string, data []byte) (*Location, error) { // Fill in the cache with information about right now, // since that will be the most common lookup. - sec := now() + sec := nowSec() for i := range tx { if tx[i].when <= sec && (i+1 == len(tx) || sec < tx[i+1].when) { l.cacheStart = tx[i].when @@ -605,7 +605,7 @@ func gorootZoneSource(goroot string) (string, bool) { return goroot + "/lib/time/zoneinfo.zip", true } -func now() (sec int64) { +func nowSec() (sec int64) { var tv time.Timespec time.ClockGettime(0, &tv) return int64(tv.Sec)