github.com/goplusjs/gopherjs@v1.2.6-0.20211206034512-f187917453b8/tests/testdata/time_inexternalization.go (about)

     1  package main
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/gopherjs/gopherjs/js"
     7  )
     8  
     9  var _ = time.Sleep // Force "time" package to be imported but let time.Time and time.Unix be DCEed since they're not used.
    10  
    11  func main() {
    12  	// Excercise externalization of Go struct (with its special handling of time.Time).
    13  	js.Global.Get("console").Call("log", struct{ S string }{"externalization ok"})
    14  
    15  	// Excercise internalization of JavaScript Date object (with its special handling of time.Time).
    16  	date := js.Global.Get("Date").New("2015-08-29T20:56:00.869Z").Interface()
    17  	js.Global.Set("myDate", date)
    18  	js.Global.Get("console").Call("log", js.Global.Get("myDate").Call("toUTCString"))
    19  }