Last active
May 25, 2022 16:37
-
-
Save mishaxz/fabfbb178fce3c94e12b1d6ff47ed880 to your computer and use it in GitHub Desktop.
CopyQ Script: Selected Date Text to yyyy-MM-dd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
copyq: | |
if (!copy()) | |
abort() | |
var text = str(clipboard()) | |
text = text.replace("st","") | |
.replace("nd","") | |
.replace("rd","") | |
.replace("th","") | |
const yourDate = new Date(text) | |
const offset = yourDate.getTimezoneOffset() | |
yourDate = new Date(yourDate.getTime() - (offset*60*1000)) | |
const dd = yourDate.toISOString().split('T')[0] | |
/* see: https://stackoverflow.com/questions/23593052/format-javascript-date-as-yyyy-mm-dd */ | |
copy(dd) | |
paste() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
note: it stopped working on v6 of Copy-Q... I was using 2.something before when it worked. I guess from around 2020. So try an older version.. maybe the most recent 2.x version?