Skip to content

Instantly share code, notes, and snippets.

@davebrny
Last active March 13, 2018 12:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davebrny/5155f65b53e50f4ddf615cd464c092a9 to your computer and use it in GitHub Desktop.
Save davebrny/5155f65b53e50f4ddf615cd464c092a9 to your computer and use it in GitHub Desktop.
πŸ“† (autohotkey) - hotstrings to quickly type various date formats
#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
*/
@davebrny
Copy link
Author

davebrny commented Feb 12, 2017

quick dates

(all hotstrings end with a ; semi-colon)

remove the comment on line 4 to have the hotstrings send without needing to type a space at the end

trigger result
d; > 1st (current date)
dy; > Monday (current day)
w; > 52 (current week number)
m; > January (current month)
y; > 2016 (current year)
Β 
date; > 31st December 2016 (full date)
sdate; > 31 Dec 2016 (short date)
ndate; > 31 12 2016 (date in numbers)
fdate; > 2016-12-31 (for file/folder names)
Β 
1; > 1st (1-31)
mon; > Monday (mon - fri)
jan; > January (jan - dec)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment