-
Notifications
You must be signed in to change notification settings - Fork 197
Add dadd package #228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add dadd package #228
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # dadd - Date Add | ||
|
|
||
| This package is an utility for quick date calculation like insert the date that is +12 from tomorrow, | ||
| or -5 day from today. | ||
|
|
||
| The package contain only one trigger that is :dadd (short for date add). | ||
|
|
||
|  | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the inclusion of the screenshot. We might find the Hub frontend fails as a result, however. Let's see!
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't remove the screenshot, please let me know what was the result. |
||
|
|
||
| The form has two field: | ||
| - Day num: Number of days to add or extract. For extraction use negative number. | ||
| - Date base (YYYY-MM-DD format): The date that will be used for add or extract. 'Today' and 'Now' are also valid values. 'Today' is the default. | ||
|
undergrinder marked this conversation as resolved.
Outdated
|
||
|
|
||
| The output will be also in YYYY-MM-DD format. | ||
|
|
||
| # Installation | ||
|
undergrinder marked this conversation as resolved.
Outdated
|
||
|
|
||
| ``` | ||
| espanso install dadd | ||
| espanso restart | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| name: "dadd" | ||
| title: "Date add package" | ||
| description: An utility for quick date calculations | ||
|
undergrinder marked this conversation as resolved.
Outdated
|
||
| homepage: "https://github.com/undergrinder/espanso-hub/tree/main/packages/dadd/0.1.0" | ||
| version: 0.1.0 | ||
| author: undergrinder | ||
| tags: ["math", "utility"] | ||
|
undergrinder marked this conversation as resolved.
Outdated
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| matches: | ||
| - trigger: ":dadd" | ||
| replace: "{{result_dateadd}}" | ||
| vars: | ||
| - name: "input_dateadd" | ||
| type: "form" | ||
| params: | ||
| layout: | | ||
| Day num: [[dayTimeDelta]] | ||
| Date base (YYYY-MM-DD format): [[dateBase]] | ||
| fields: | ||
| dayTimeDelta: | ||
| default: "1" | ||
| dateBase: | ||
| default: "today" | ||
| - name: result_dateadd | ||
| type: script | ||
| params: | ||
| args: | ||
| - python | ||
| - -c | ||
| - | | ||
| from datetime import datetime, timedelta | ||
| clean_input = '{{input_dateadd.dateBase}}'.strip("' \"").replace('.', '-') | ||
|
undergrinder marked this conversation as resolved.
Outdated
|
||
| if clean_input in ['now', 'today']: | ||
|
undergrinder marked this conversation as resolved.
Outdated
|
||
| dt = datetime.today().date() | ||
| else: | ||
| dt = datetime.strptime(clean_input, '%Y-%m-%d') | ||
| print(f"{dt + timedelta(days=int('{{input_dateadd.dayTimeDelta}}'))}") | ||
|
undergrinder marked this conversation as resolved.
Outdated
|
||
Uh oh!
There was an error while loading. Please reload this page.