MCPcopy Index your code
hub / github.com/containers/toolbox / extractTimeZoneFromLocalTimeSymLink

Function extractTimeZoneFromLocalTimeSymLink

src/cmd/initContainer.go:1167–1187  ·  view source on GitHub ↗
(path string)

Source from the content-addressed store, hash-verified

1165}
1166
1167func extractTimeZoneFromLocalTimeSymLink(path string) (string, error) {
1168 zoneInfoRoots := []string{
1169 "/run/host/usr/share/zoneinfo",
1170 "/usr/share/zoneinfo",
1171 }
1172
1173 for _, root := range zoneInfoRoots {
1174 if !strings.HasPrefix(path, root) {
1175 continue
1176 }
1177
1178 timeZone, err := filepath.Rel(root, path)
1179 if err != nil {
1180 return "", fmt.Errorf("failed to extract time zone: %w", err)
1181 }
1182
1183 return timeZone, nil
1184 }
1185
1186 return "", errors.New("/etc/localtime points to unknown location")
1187}
1188
1189func updateTimeZoneFromLocalTime() error {
1190 localTimeEvaled, err := filepath.EvalSymlinks("/etc/localtime")

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…