diff options
| -rw-r--r-- | interface-definitions/system-option.xml.in | 20 | ||||
| -rwxr-xr-x | src/conf_mode/system-option.py | 12 | 
2 files changed, 31 insertions, 1 deletions
| diff --git a/interface-definitions/system-option.xml.in b/interface-definitions/system-option.xml.in index efab50a66..b1b5f7fae 100644 --- a/interface-definitions/system-option.xml.in +++ b/interface-definitions/system-option.xml.in @@ -144,6 +144,26 @@                 <valueless/>               </properties>             </leafNode> +           <leafNode name="time-format"> +            <properties> +              <help>System time-format</help> +              <completionHelp> +                <list>12-hour 24-hour</list> +              </completionHelp> +              <valueHelp> +                <format>12-hour</format> +                <description>12 hour time format</description> +              </valueHelp> +              <valueHelp> +                <format>24-hour</format> +                <description>24 hour time format</description> +              </valueHelp> +              <constraint> +                <regex>(12-hour|24-hour)</regex> +              </constraint> +            </properties> +            <defaultValue>12-hour</defaultValue> +           </leafNode>          </children>        </node>      </children> 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() | 
