Skip to content

Commit

Permalink
Add AMPM format
Browse files Browse the repository at this point in the history
  • Loading branch information
fedecalendino committed Jan 13, 2023
1 parent 3808587 commit 5a52fae
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 14 deletions.
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,20 @@
#### Usage:

##### Default Format
![usage vars](screenshots/usage.png)
![default](screenshots/usage.png)

- Hold `alt` to copy ISO with microseconds
![usage vars](screenshots/usage_alt.png)
![alt modifier](screenshots/usage_alt.png)

- Hold `cmd` to copy ISO without microseconds
![usage vars](screenshots/usage_cmd.png)
![cmd modifier](screenshots/usage_cmd.png)

##### AM/PM format
![ampm](screenshots/usage_ampm.png)

##### ISO Format (with microseconds)
![usage vars](screenshots/usage_iso_with_microseconds.png)
![iso with microseconds](screenshots/usage_iso_with_microseconds.png)

##### ISO Format (without microseconds)
![usage vars](screenshots/usage_iso_without_microseconds.png)
![iso without microseconds](screenshots/usage_iso_without_microseconds.png)

12 changes: 8 additions & 4 deletions info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -1845,12 +1845,16 @@
<key>config</key>
<dict>
<key>default</key>
<string>FORMAT_DEFAULT</string>
<string>FORMAT_DEFAULT_24HS</string>
<key>pairs</key>
<array>
<array>
<string>Default format</string>
<string>FORMAT_DEFAULT</string>
<string>Default format (24hs)</string>
<string>FORMAT_DEFAULT_24HS</string>
</array>
<array>
<string>Default format (am/pm)</string>
<string>FORMAT_DEFAULT_12HS</string>
</array>
<array>
<string>ISO8601 (with microseconds)</string>
Expand Down Expand Up @@ -9853,7 +9857,7 @@
</dict>
</array>
<key>version</key>
<string>2.0.0</string>
<string>2.1.0</string>
<key>webaddress</key>
<string>https://github.com/fedecalendino/alfred-world-clock</string>
</dict>
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "World Clock"
version = "2.0.0"
version = "2.1.0"
description = "Check time in multiple timezones."
documentation = "https://github.com/fedecalendino/alfred-world-clock/blob/main/README.md"
homepage = "https://github.com/fedecalendino/alfred-world-clock"
Expand Down
Binary file modified screenshots/config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/config_format.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/usage_ampm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 9 additions & 3 deletions src/formatters.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
from datetime import datetime


def default(now: datetime) -> str:
return now.strftime("%H%:%M:%S (%B %d, %Y)")
def default_12hs(now: datetime) -> str:
return now.strftime("%I:%M:%S %p (%B %d, %Y)")


def default_24hs(now: datetime) -> str:
return now.strftime("%H:%M:%S (%B %d, %Y)")


def iso8601(now: datetime) -> str:
Expand All @@ -14,7 +18,9 @@ def iso8601_without_microseconds(now: datetime) -> str:


FORMATTERS = {
"FORMAT_DEFAULT": default,
"FORMAT_DEFAULT": default_24hs,
"FORMAT_DEFAULT_12HS": default_12hs,
"FORMAT_DEFAULT_24HS": default_24hs,
"FORMAT_ISO8601_WITH_MICROSECONDS": iso8601,
"FORMAT_ISO8601_WITHOUT_MICROSECONDS": iso8601_without_microseconds,
}
2 changes: 1 addition & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def get_timezones(workflow, home_tz):


def get_formatter(workflow):
timestamp_format = workflow.env.get("TIMESTAMP_FORMAT", formatters.default)
timestamp_format = workflow.env.get("TIMESTAMP_FORMAT", "FORMAT_DEFAULT")
return formatters.FORMATTERS[timestamp_format]


Expand Down

0 comments on commit 5a52fae

Please sign in to comment.