Skip to content

Commit

Permalink
use default of current timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed Jan 16, 2026
1 parent 9cdf8e9 commit 0ef83e0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
10 changes: 10 additions & 0 deletions local-app/python-tools/sso-tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 9 additions & 6 deletions local-app/python-tools/sso-tools/sso-create-sc-group.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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}")

Expand Down

0 comments on commit 0ef83e0

Please sign in to comment.