10 examples of 'golang timezone' in Go

Every line of 'golang timezone' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Go code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
444func timezoneToLocation(hour int64, minute int64) *time.Location {
445 if minute != 0 || hour > 14 || hour < -12 {
446 // create location with FixedZone
447 var name string
448 if hour < 0 {
449 name = strconv.FormatInt(hour, 10) + ":"
450 } else {
451 name = "+" + strconv.FormatInt(hour, 10) + ":"
452 }
453 if minute == 0 {
454 name += "00"
455 } else {
456 if minute < 10 {
457 name += "0"
458 }
459 name += strconv.FormatInt(minute, 10)
460 }
461 return time.FixedZone(name, (3600*int(hour))+(60*int(minute)))
462 }
463
464 // use location from timeLocations cache
465 return timeLocations[12+hour]
466}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

313func timezoneAbbr(g *Goment) string {
314 tz, _ := g.ToTime().Zone()
315 return tz
316}
65func genTimezone(offset int) *time.Location {
66 var offsetSign string
67 var toffset int
68 if offset < 0 {
69 offsetSign = "-"
70 toffset = -offset
71 } else {
72 offsetSign = "+"
73 toffset = offset
74 }
75 glog.V(2).Infof("offset: %v", offset)
76 return time.FixedZone(
77 fmt.Sprintf("%v%02d%02d",
78 offsetSign, toffset/60, toffset%60), int(offset)*60)
79}
1131func (x *PostgresqlHostConfig11) GetTimezone() string {
1132 if x != nil {
1133 return x.Timezone
1134 }
1135 return ""
1136}
1131func (x *PostgresqlHostConfig12) GetTimezone() string {
1132 if x != nil {
1133 return x.Timezone
1134 }
1135 return ""
1136}
1139func (x *PostgresqlHostConfig10) GetTimezone() string {
1140 if x != nil {
1141 return x.Timezone
1142 }
1143 return ""
1144}
310func (m *CreateRequest) GetTz() *wrappers.StringValue {
311 if m != nil {
312 return m.Tz
313 }
314 return nil
315}
85func (a fakeAddress) TimeZone() string {
86 return Fetch("address.time_zone")
87}
1003func (a *Applier) validateAndReadTimeZone() error {
1004 query := `select @@global.time_zone`
1005 if err := a.db.QueryRow(query).Scan(&a.mysqlContext.TimeZone); err != nil {
1006 return err
1007 }
1008
1009 a.logger.Printf("mysql.applier: Will use time_zone='%s' on applier", a.mysqlContext.TimeZone)
1010 return nil
1011}
73func (m *EventStrings) GetTimezone() string {
74 if m != nil {
75 return m.Timezone
76 }
77 return ""
78}

Related snippets