github.com/bananabytelabs/wazero@v0.0.0-20240105073314-54b22a776da8/internal/gojs/time.go (about)

     1  package gojs
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/bananabytelabs/wazero/api"
     7  	"github.com/bananabytelabs/wazero/internal/gojs/custom"
     8  	"github.com/bananabytelabs/wazero/internal/gojs/goos"
     9  )
    10  
    11  var (
    12  	// jsDateConstructor returns jsDate.
    13  	//
    14  	// This is defined as `Get("Date")` in zoneinfo_js.go time.initLocal
    15  	jsDateConstructor = newJsVal(goos.RefJsDateConstructor, custom.NameDate)
    16  
    17  	// jsDate is used inline in zoneinfo_js.go for time.initLocal.
    18  	// `.Call("getTimezoneOffset").Int()` returns a timezone offset.
    19  	jsDate = newJsVal(goos.RefJsDate, custom.NameDate).
    20  		addFunction(custom.NameDateGetTimezoneOffset, jsDateGetTimezoneOffset{})
    21  )
    22  
    23  // jsDateGetTimezoneOffset implements jsFn
    24  type jsDateGetTimezoneOffset struct{}
    25  
    26  func (jsDateGetTimezoneOffset) invoke(context.Context, api.Module, ...interface{}) (interface{}, error) {
    27  	return uint32(0), nil // UTC
    28  }