podman/pkg/machine/ignition_linux.go
Brent Baude a86495ea6f Set machine timezone
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>
2021-12-16 12:40:20 -06:00

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
}