diff options
author | Viacheslav Hletenko <v.gletenko@vyos.io> | 2023-08-01 09:34:24 +0000 |
---|---|---|
committer | Viacheslav Hletenko <v.gletenko@vyos.io> | 2023-08-01 09:34:24 +0000 |
commit | 7fd6d8c0e99ff4cb566598af65d8915c658ed749 (patch) | |
tree | 2f5102609ef76a3c3d3e58be3b0204f649f2836a /src/conf_mode | |
parent | 348cc302258b59b3e31c4aeb7ccc432086908edc (diff) | |
download | vyos-1x-7fd6d8c0e99ff4cb566598af65d8915c658ed749.tar.gz vyos-1x-7fd6d8c0e99ff4cb566598af65d8915c658ed749.zip |
T5374: Add system option time-format 12 or 24 hours
Ability to set locate time format 12|24-hour
set system option time-format 12-hour|24-hour
$ date
Tue Aug 1 12:33:45 PM EEST 2023
$ date
Tue 1 Aug 12:34:09 EEST 2023
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-x | src/conf_mode/system-option.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/conf_mode/system-option.py b/src/conf_mode/system-option.py index 5172b492e..1495e9223 100755 --- a/src/conf_mode/system-option.py +++ b/src/conf_mode/system-option.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -# Copyright (C) 2019-2022 VyOS maintainers and contributors +# Copyright (C) 2019-2023 VyOS maintainers and contributors # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 or later as @@ -36,6 +36,11 @@ airbag.enable() curlrc_config = r'/etc/curlrc' ssh_config = r'/etc/ssh/ssh_config.d/91-vyos-ssh-client-options.conf' systemd_action_file = '/lib/systemd/system/ctrl-alt-del.target' +time_format_to_locale = { + '12-hour': 'en_US.UTF-8', + '24-hour': 'en_GB.UTF-8' +} + def get_config(config=None): if config: @@ -143,6 +148,11 @@ def apply(options): else: cmd('systemctl disable root-partition-auto-resize.service') + # Time format 12|24-hour + if 'time_format' in options: + time_format = time_format_to_locale.get(options['time_format']) + cmd(f'localectl set-locale LC_TIME={time_format}') + if __name__ == '__main__': try: c = get_config() |