Last active
March 13, 2018 12:27
-
-
Save davebrny/5155f65b53e50f4ddf615cd464c092a9 to your computer and use it in GitHub Desktop.
π (autohotkey) - hotstrings to quickly type various date formats
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
#noEnv | |
#singleInstance, force | |
sendMode, input | |
; #hotstring * ; send each hotstring without needing to type an endkey (space, enter etc) | |
sp := a_space ; send a space after each hotstring | |
return ; ----------------------------------------------------------------------- | |
::d;:: ; todays date (1st) | |
send % ordinal(LTrim(A_DD, "0")) . sp | |
return | |
::dy;:: ; todays day (e.g. Monday) | |
send % A_DDDD . sp | |
return | |
::w;:: ; current week number (16) | |
send % LTrim(subStr(A_YWeek, -1, 2), "0") . sp | |
return | |
::m;:: ; this month (January) | |
send % A_MMMM . sp | |
return | |
::y;:: ; this year (2015) | |
send % A_YYYY . sp | |
return | |
::date;:: ; 31st December 2015 | |
send % ordinal(LTrim(A_DD, "0")) " " A_MMMM " " A_YYYY . sp | |
return | |
::sdate;:: ; 31 Dec 2015 (short date) | |
send % LTrim(A_DD, "0") " " A_MMM " " A_YYYY . sp | |
return | |
::ndate;:: ; 31 12 2015 (date in numbers) | |
send % LTrim(A_DD, "0") " " A_MM " " A_YYYY . sp | |
return | |
::fdate;:: ; 2015-12-31 (for file or folder names) | |
send % A_YYYY "-" A_MM "-" A_DD . sp | |
return | |
::1;:: ; 1; ---> 1st | |
::2;:: ; 2; ---> 2nd etc | |
::3;:: | |
::4;:: | |
::5;:: | |
::6;:: | |
::7;:: | |
::8;:: | |
::9;:: | |
::10;:: | |
::11;:: | |
::12;:: | |
::13;:: | |
::14;:: | |
::15;:: | |
::16;:: | |
::17;:: | |
::18;:: | |
::19;:: | |
::20;:: | |
::21;:: | |
::22;:: | |
::23;:: | |
::24;:: | |
::25;:: | |
::26;:: | |
::27;:: | |
::28;:: | |
::29;:: | |
::30;:: | |
::31;:: | |
send % ordinal(regExReplace(a_thisLabel, "[^0-9]")) . sp | |
return | |
::mon;:: ; mon; ---> Monday | |
::tue;:: | |
::wed;:: | |
::thu;:: | |
::fri;:: | |
::sat;:: | |
::sun;:: | |
::jan;:: ; jan; ---> January | |
::feb;:: | |
::mar;:: | |
::apr;:: | |
::may;:: | |
::jun;:: | |
::jul;:: | |
::aug;:: | |
::sep;:: | |
::oct;:: | |
::nov;:: | |
::dec;:: | |
stringTrimLeft, hotstring, a_thisLabel, 2 | |
for what, with in { "mon;" : "Monday" | |
, "tue;" : "Tuesday" | |
, "wed;" : "Wednesday" | |
, "thu;" : "Thursday" | |
, "fri;" : "Friday" | |
, "sat;" : "Saturday" | |
, "sun;" : "Sunday" | |
, "jan;" : "January" | |
, "feb;" : "February" | |
, "mar;" : "March" | |
, "apr;" : "April" | |
, "may;" : "May" | |
, "jun;" : "June" | |
, "jul;" : "July" | |
, "aug;" : "August" | |
, "sep;" : "September" | |
, "oct;" : "October" | |
, "nov;" : "November" | |
, "dec;" : "December" } | |
stringReplace, hotstring, hotstring, % what, % with, all | |
send % hotstring . sp | |
return | |
#hotstring *0 | |
ordinal(number) { | |
stringRight, last_digit, number, 1 | |
stringRight, last_two , number, 2 | |
if (last_digit = 1) | |
suffix := "st" | |
else if (last_digit = 2) | |
suffix := "nd" | |
else if (last_digit = 3) | |
suffix := "rd" | |
else suffix := "th" | |
if last_two contains 11,12,13 | |
suffix := "th" | |
return number . suffix | |
} | |
/* | |
[script info] | |
version = 2.1 | |
description = hotstrings to quickly type various date formats | |
author = davebrny | |
source = https://gist.github.com/davebrny/5155f65b53e50f4ddf615cd464c092a9 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
quick dates
d;
dy;
w;
m;
y;
date;
sdate;
ndate;
fdate;
1;
mon;
jan;