Skip to content
Snippets Groups Projects
Commit efe1cc90 authored by James Page's avatar James Page
Browse files

Merge branch '35-store-current-location-so-that-it-is-not-loaded-from-disk-each-time' into 'main'

Resolve "Store current location so that it is not loaded from disk each time"

See merge request !39
parents a2c06864 95591165
Branches
Tags v1.87.0
1 merge request!39Resolve "Store current location so that it is not loaded from disk each time"
...@@ -8,6 +8,8 @@ import ( ...@@ -8,6 +8,8 @@ import (
const TimeZoneString = "Africa/Johannesburg" const TimeZoneString = "Africa/Johannesburg"
var currentLocation *time.Location
func DateLayoutYearMonthDayTimeT() string { func DateLayoutYearMonthDayTimeT() string {
layout := "2006-01-02T15:04:05" layout := "2006-01-02T15:04:05"
return layout return layout
...@@ -81,8 +83,10 @@ func DateDBFormattedStringDateOnly(date time.Time) string { ...@@ -81,8 +83,10 @@ func DateDBFormattedStringDateOnly(date time.Time) string {
} }
func CurrentLocation() *time.Location { func CurrentLocation() *time.Location {
loc, _ := time.LoadLocation(TimeZoneString) if currentLocation == nil {
return loc currentLocation, _ = time.LoadLocation(TimeZoneString)
}
return currentLocation
} }
func DateLocal(date *time.Time) { func DateLocal(date *time.Time) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment