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
How to insert tomorow and yesterday dates? #311
Comments
Hey, This could be a very useful feature indeed, I'll add it to the roadmap! Cheers :) |
You can do it with shell integration if your system has the
I don't think this is helpful for windows users, though. |
For those who uses Windows10 with Linux Subsystem - trigger: ":1date"
replace: "{{output}}"
vars:
- name: output
type: shell
params:
cmd: "bash -c 'date +%Y-%m-%d -d +1day'"
|
Hey @mrjackphil, - trigger: ":1date"
replace: "{{output}}"
vars:
- name: output
type: shell
params:
cmd: "date +%Y-%m-%d -d +1day"
shell: wsl Cheers :) |
@federico-terzi Just tried it and it works not as I expected. Maybe because of Cyrillic symbols or different format. While my configuration returns:
when tried yours I receive:
|
Thank you for pointing that out @mrjackphil, this seems like a bug! Could you please tell me which language are you using? If I manage to reproduce it I might be able to get a solution :) |
I'm using a Windows 10 Home Edition. Russian language. |
All right, thank you @mrjackphil |
Just a heads up, |
@mrrcollins thanks for your feedback, I've opened an issue to make this handling more convenient #353 |
Just wanted to let you know that the next release (0.7.0) will support this out of the box. In particular, you will be able to specify an - trigger: ":yesterday"
replace: "{{mytime}}"
vars:
- name: mytime
type: date
params:
format: "%c"
offset: -86400
- trigger: ":tomorrow"
replace: "{{mytime}}"
vars:
- name: mytime
type: date
params:
format: "%c"
offset: 86400 |
Very good!!! |
PLS @mrjackphil
It does nothing! (W10) |
@jczanfona You should be able to get it working by specifying the - trigger: ":fecha"
replace: "{{output}}"
vars:
- name: output
type: shell
params:
cmd: "date /t"
shell: cmd By default espanso uses Powershell on Windows, which as far as I know does not support the Cheers :) |
TX a lot @federico-terzi |
Hi, is there a good possibility to make this dynamic? On MAC OS I am using Keyboard Maestro to create a popup-box, enter a number X, and the output is the future date (today + X days). I would like to do something similar on Windows with espanso as well. Any ideas for that? Thanks,
|
Hey @mhofherr,
Not out of the box, but you should be able to do so with a custom script :) Here's something to get started:
Cheers :) |
Thanks a lot for fast reply! Will have a look at the indicated examples. |
Followup-question: I copled together the following:
I know that "(Get-Date).AddDays(1).ToString('yyyy-MM-dd')" delivers today's date +1 on powershell. With the variable it does not work. Do you have any insights what I am doing wrong here (Windows 10; Powershell)? Thanks, |
Hey @mhofherr , I'm not a PowerShell expert, but according to this post you might want to use - trigger: ".mydate"
replace: "{{mydate}}"
vars:
- name: form1
type: form
params:
layout: |
Add days {{name}}
- name: newdate
type: shell
params:
cmd: "(Get-Date).AddDays(${ESPANSO_FORM1_NAME}).ToString('yyyy-MM-dd')"
shell: powershell Let me know if that helps! Cheers :) |
Almost, but your link did the trick => the following works for me: Thanks again, |
Hey, This code does not work. Maybe I am too optimistic when it comes to injecting variables? # calc days
- trigger: "ddc"
replace: "{{result_day}}"
vars:
- name: frm_day # get user input (number of days)
type: form
params:
layout: |
Enter number of days: [[days]]
- name: calc_offset # calculate offset in seconds
type: shell
params:
cmd: "echo '86400 * {{frm_day.days}}' | bc"
- name: result_day
type: date
params:
offset: "{{calc_offset}}" # this variable is not injected
format: "%Y-%m-%d" Thanks, |
Hey, I found a solution: # calc days
- trigger: "ddc"
replace: "{{result_day}}"
vars:
- name: frm_day # get user input (number of days)
type: form
params:
layout: |
Enter number of days: [[days]]
- name: result_day # calculate offset in shell
type: shell
params:
cmd: "date -d \"{{frm_day.days}} days\" -u +%Y-%m-%d" But I am still curious to know whether offset parameter can receive an injected variable. Cheers, |
No description provided.
The text was updated successfully, but these errors were encountered: