Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions packages/dadd/0.1.0/README.md
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).
Comment thread
undergrinder marked this conversation as resolved.
Outdated

![screenshot](screenshot.png)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The 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!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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.
Comment thread
undergrinder marked this conversation as resolved.
Outdated

The output will be also in YYYY-MM-DD format.

# Installation
Comment thread
undergrinder marked this conversation as resolved.
Outdated

```
espanso install dadd
espanso restart
```
7 changes: 7 additions & 0 deletions packages/dadd/0.1.0/_manifest.yml
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
Comment thread
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"]
Comment thread
undergrinder marked this conversation as resolved.
Outdated
29 changes: 29 additions & 0 deletions packages/dadd/0.1.0/package.yml
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('.', '-')
Comment thread
undergrinder marked this conversation as resolved.
Outdated
if clean_input in ['now', 'today']:
Comment thread
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}}'))}")
Comment thread
undergrinder marked this conversation as resolved.
Outdated
Binary file added packages/dadd/0.1.0/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.