Skip to content

Commit

Permalink
make timezone-aware
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed Jan 16, 2026
1 parent 1b5d20f commit 9cdf8e9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
14 changes: 14 additions & 0 deletions local-app/python-tools/sso-tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,23 @@ Because `created_time` is now an object rather than a pre-formatted string, you
* **Full Time with Seconds**: `{{ created_time.strftime('%H:%M:%S') }}`
* **Year Only**: `{{ created_time.year }}`

### Working with Timezones in Jinja2

Since `created_time` now includes timezone data, you can output it in various ways in your templates:

* **Standard ISO with Offset**: `{{ created_time.isoformat() }}`
* *Output: 2026-01-16T16:04:32.123456+00:00*


* **Specific Format**: `{{ created_time.strftime('%Y-%m-%d %H:%M %Z') }}`
* *Output: 2026-01-16 16:04 UTC*

## CHANGELOG

#### v1.0.7

* Switched `created_time` to a timezone-aware UTC `datetime` object to ensure consistent timestamps across different server locations.

#### v1.0.6

* Changed `created_time` from a string to a native Python `datetime` object, allowing for custom formatting within Jinja2 templates using `.strftime()`.
Expand Down
14 changes: 7 additions & 7 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
from datetime import datetime, timezone
from jinja2 import Environment, FileSystemLoader

# Version History:
# 1.0.0 - 1.0.5: Basic logic, lowercase, force, description, metadata strings
# 1.0.6: Passed created_time as a datetime object for flexible template formatting
__version__ = "1.0.6"
# 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"

def create_sc_group():
parser = argparse.ArgumentParser(description="Automate file creation from templates.")
Expand All @@ -23,9 +23,9 @@ def create_sc_group():

args = parser.parse_args()

# 1. Setup metadata
# 1. Setup metadata (Timezone Aware)
script_name = os.path.basename(__file__)
now = datetime.now() # Native datetime object
now = datetime.now(timezone.utc)

# 2. Determine names and force to lowercase
raw_group = args.group if args.group else Path.cwd().name
Expand Down Expand Up @@ -67,7 +67,7 @@ def create_sc_group():
"description": args.description or "",
"script_name": script_name,
"version": __version__,
"created_time": now # Passed as object
"created_time": now
}

# 8. Process files
Expand Down

0 comments on commit 9cdf8e9

Please sign in to comment.