code.gitea.io/gitea@v1.22.3/modules/setting/time.go (about)

     1  // Copyright 2023 The Gitea Authors. All rights reserved.
     2  // SPDX-License-Identifier: MIT
     3  
     4  package setting
     5  
     6  import (
     7  	"time"
     8  
     9  	"code.gitea.io/gitea/modules/log"
    10  )
    11  
    12  // DefaultUILocation is the location on the UI, so that we can display the time on UI.
    13  var DefaultUILocation = time.Local
    14  
    15  func loadTimeFrom(rootCfg ConfigProvider) {
    16  	zone := rootCfg.Section("time").Key("DEFAULT_UI_LOCATION").String()
    17  	if zone != "" {
    18  		var err error
    19  		DefaultUILocation, err = time.LoadLocation(zone)
    20  		if err != nil {
    21  			log.Fatal("Load time zone failed: %v", err)
    22  		}
    23  		log.Info("Default UI Location is %v", zone)
    24  	}
    25  	if DefaultUILocation == nil {
    26  		DefaultUILocation = time.Local
    27  	}
    28  }