Skip to content

Commit 8d282e7

Browse files
authored
Merge pull request #228 from undergrinder/main
Add dadd package Thank you.
2 parents bd50f11 + e6cbe2e commit 8d282e7

4 files changed

Lines changed: 51 additions & 0 deletions

File tree

packages/dadd/0.1.0/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# dadd - Date Add
2+
3+
This package is a utility for quick date calculations like insert the date that is +12 from tomorrow,
4+
or -5 days from today.
5+
6+
The package contains only one trigger that is :dadd (short for date add).
7+
8+
![screenshot](screenshot.png)
9+
10+
The form has two fields:
11+
- Day num: Number of days to add or subtract. For subtraction use negative numbers.
12+
- 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.
13+
14+
The output will be also in YYYY-MM-DD format.

packages/dadd/0.1.0/_manifest.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
name: "dadd"
2+
title: "Date add package"
3+
description: A utility for quick date calculations
4+
homepage: "https://github.com/undergrinder/espanso-hub/tree/main/packages/dadd/0.1.0"
5+
version: 0.1.0
6+
author: undergrinder
7+
tags: ["math", "utility", "date", "python", "crossplatform"]

packages/dadd/0.1.0/package.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
matches:
2+
- trigger: ":dadd"
3+
replace: "{{result_dateadd}}"
4+
vars:
5+
- name: "input_dateadd"
6+
type: "form"
7+
params:
8+
layout: |
9+
Day num: [[dayTimeDelta]]
10+
Date base (YYYY-MM-DD format): [[dateBase]]
11+
fields:
12+
dayTimeDelta:
13+
default: "1"
14+
dateBase:
15+
default: "today"
16+
- name: result_dateadd
17+
type: script
18+
params:
19+
args:
20+
- python
21+
- -c
22+
- |
23+
from datetime import datetime, timedelta
24+
clean_input = '{{input_dateadd.dateBase}}'.strip("' \"").replace('.', '-').lower()
25+
if clean_input in ['now', 'today']:
26+
dt = datetime.today().date()
27+
else:
28+
dt = datetime.strptime(clean_input, '%Y-%m-%d').date()
29+
result = dt + timedelta(days=int('{{input_dateadd.dayTimeDelta}}'))
30+
print(result.strftime('%Y-%m-%d'))

packages/dadd/0.1.0/screenshot.png

12.7 KB
Loading

0 commit comments

Comments
 (0)