Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 14 additions & 0 deletions packages/dadd/0.1.0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# dadd - Date Add

This package is a utility for quick date calculations like insert the date that is +12 from tomorrow,
or -5 days from today.

The package contains only one trigger that is :dadd (short for date add).

![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 fields:
- Day num: Number of days to add or subtract. For subtraction use negative numbers.
- Date base (YYYY-MM-DD format): The date that will be used to add or subtract days. 'Today' and 'Now' are also valid values. 'Today' is the default.

The output will be also in YYYY-MM-DD format.
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: A utility for quick date calculations
homepage: "https://github.com/undergrinder/espanso-hub/tree/main/packages/dadd/0.1.0"
version: 0.1.0
author: undergrinder
tags: ["math", "utility", "date", "python", "crossplatform"]
30 changes: 30 additions & 0 deletions packages/dadd/0.1.0/package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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('.', '-').lower()
if clean_input in ['now', 'today']:
dt = datetime.today().date()
else:
dt = datetime.strptime(clean_input, '%Y-%m-%d').date()
result = dt + timedelta(days=int('{{input_dateadd.dayTimeDelta}}'))
print(result.strftime('%Y-%m-%d'))
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.
Loading