Last active
October 13, 2025 09:49
-
-
Save smeech/b9f1e793cf63ee42e8512450ae85dc98 to your computer and use it in GitHub Desktop.
[Date_Time] Espanso trigger to output time and date in another timezone. Requires Python and its pytz library. Somewhat redundant from Espanso v2.3.0. #espanso #python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Espanso trigger to output time and date in another timezone | |
| # Requires Python and its pytz library | |
| matches: | |
| - trigger: :tzdate | |
| replace: '{{output}}' | |
| vars: | |
| - name: zones | |
| type: script | |
| params: | |
| args: | |
| - python | |
| - -c | |
| - | | |
| import pytz | |
| print("\n".join(pytz.all_timezones)) | |
| - name: zone_choice | |
| type: form | |
| params: | |
| layout: 'Pick a time-zone: [[zone]]' | |
| fields: | |
| zone: | |
| type: list | |
| values: '{{zones}}' | |
| default: Europe/London | |
| - name: output | |
| type: script | |
| params: | |
| args: | |
| - python | |
| - -c | |
| - | | |
| import pytz; from datetime import datetime | |
| timezone = pytz.timezone('{{zone_choice.zone}}') | |
| # Get the current date and time in UTC | |
| utc_now = datetime.utcnow().replace(tzinfo=pytz.utc) | |
| # Convert UTC time to the specified timezone | |
| local_time = utc_now.astimezone(timezone) | |
| print("Current date and time in", timezone, "is:", local_time.strftime('%F %T')) |
Author
i did the same π ... it's just way faster with the internal data type, and not as wasteful ...
# this IS discouraged, yet this is not a web app, this is a one-shot tool.
locale.setlocale(locale.LC_ALL, ".".join(locale.getlocale()))works here.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i did the same π ... it's just way faster with the internal data type, and not as wasteful ...