...
  
    Source file
    src/time/zoneinfo_js.go
  
  
    Documentation: time
  
     1  
     2  
     3  
     4  
     5  
     6  
     7  package time
     8  
     9  import (
    10  	"internal/itoa"
    11  	"syscall/js"
    12  )
    13  
    14  var platformZoneSources = []string{
    15  	"/usr/share/zoneinfo/",
    16  	"/usr/share/lib/zoneinfo/",
    17  	"/usr/lib/locale/TZ/",
    18  }
    19  
    20  func initLocal() {
    21  	localLoc.name = "Local"
    22  
    23  	z := zone{}
    24  	d := js.Global().Get("Date").New()
    25  	offset := d.Call("getTimezoneOffset").Int() * -1
    26  	z.offset = offset * 60
    27  	
    28  	
    29  	
    30  	
    31  	
    32  	z.name = "UTC"
    33  	if offset < 0 {
    34  		z.name += "-"
    35  		offset *= -1
    36  	} else {
    37  		z.name += "+"
    38  	}
    39  	z.name += itoa.Itoa(offset / 60)
    40  	min := offset % 60
    41  	if min != 0 {
    42  		z.name += ":" + itoa.Itoa(min)
    43  	}
    44  	localLoc.zone = []zone{z}
    45  }
    46  
View as plain text