From 0ef83e0cae63ef4cf212ad87edb1d7085cd538f5 Mon Sep 17 00:00:00 2001 From: badra001 Date: Fri, 16 Jan 2026 11:07:57 -0500 Subject: [PATCH] use default of current timezone --- local-app/python-tools/sso-tools/README.md | 10 ++++++++++ .../python-tools/sso-tools/sso-create-sc-group.py | 15 +++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/local-app/python-tools/sso-tools/README.md b/local-app/python-tools/sso-tools/README.md index eaf20f90..6b64e8fd 100644 --- a/local-app/python-tools/sso-tools/README.md +++ b/local-app/python-tools/sso-tools/README.md @@ -123,8 +123,18 @@ Since `created_time` now includes timezone data, you can output it in various wa * **Specific Format**: `{{ created_time.strftime('%Y-%m-%d %H:%M %Z') }}` * *Output: 2026-01-16 16:04 UTC* +### Template Tip + +To see your local timezone name or offset in your generated files, you can use: + +* `{{ created_time.strftime('%Z %z') }}` -> Outputs something like `EST -0500` + ## CHANGELOG +#### v1.0.8 + +* Updated `created_time` to default to the system's local timezone (timezone-aware) instead of UTC. + #### v1.0.7 * Switched `created_time` to a timezone-aware UTC `datetime` object to ensure consistent timestamps across different server locations. diff --git a/local-app/python-tools/sso-tools/sso-create-sc-group.py b/local-app/python-tools/sso-tools/sso-create-sc-group.py index 7d261a1a..6fcefc1a 100755 --- a/local-app/python-tools/sso-tools/sso-create-sc-group.py +++ b/local-app/python-tools/sso-tools/sso-create-sc-group.py @@ -4,13 +4,13 @@ import sys import os from pathlib import Path -from datetime import datetime, timezone +from datetime import datetime from jinja2 import Environment, FileSystemLoader # Version History: -# 1.0.0 - 1.0.6: Logic, lowercase, force, metadata, datetime object -# 1.0.7: Made created_time timezone-aware (UTC) -__version__ = "1.0.7" +# 1.0.0 - 1.0.7: Core logic, naming, force flag, UTC metadata +# 1.0.8: Switched created_time to system local timezone-aware object +__version__ = "1.0.8" def create_sc_group(): parser = argparse.ArgumentParser(description="Automate file creation from templates.") @@ -23,9 +23,10 @@ def create_sc_group(): args = parser.parse_args() - # 1. Setup metadata (Timezone Aware) + # 1. Setup metadata (Local Timezone Aware) script_name = os.path.basename(__file__) - now = datetime.now(timezone.utc) + # .astimezone() with no args defaults to the system local timezone + now = datetime.now().astimezone() # 2. Determine names and force to lowercase raw_group = args.group if args.group else Path.cwd().name @@ -76,6 +77,7 @@ def create_sc_group(): continue if item.suffix == ".j2": + # Replace 'GROUP' with created_group and strip '.j2' new_filename = item.name.replace("GROUP", created_group).replace(".j2", "") target_path = target_dir / new_filename @@ -86,6 +88,7 @@ def create_sc_group(): print(f" [Rendered] {item.name} -> {new_filename}") else: + # Copy non-template files directly shutil.copy2(item, target_dir / item.name) print(f" [Copied] {item.name}")