mirror of
https://github.com/containers/podman.git
synced 2025-05-21 17:16:22 +08:00

Added an option to podman machine init to declare the timezone of the resulting machine. the default is to use the value of the host name or else a given timezone name like America/Chicago. Fixes: #11895 Signed-off-by: Brent Baude <bbaude@redhat.com> [NO NEW TESTS NEEDED] Signed-off-by: Brent Baude <bbaude@redhat.com>
16 lines
346 B
Go
16 lines
346 B
Go
package machine
|
|
|
|
import (
|
|
"os/exec"
|
|
"strings"
|
|
)
|
|
|
|
func getLocalTimeZone() (string, error) {
|
|
output, err := exec.Command("timedatectl", "show", "--property=Timezone").Output()
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
// Remove prepended field and the newline
|
|
return strings.TrimPrefix(strings.TrimSuffix(string(output), "\n"), "Timezone="), nil
|
|
}
|