Skip to content

Instantly share code, notes, and snippets.

@davebrny
Last active November 7, 2017 06:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davebrny/d8a361412985c494e5b3a5a2954dde5c to your computer and use it in GitHub Desktop.
Save davebrny/d8a361412985c494e5b3a5a2954dde5c to your computer and use it in GitHub Desktop.
(autohotkey) - find how many days are in a given month
days_in_month(date="") {
date := (date = "") ? (a_now) : (date)
formatTime, year, % date, yyyy
formatTime, month, % date, MM
month += 1 ; goto next month
if (month > 12)
year += 1, month := 1 ; goto next year, reset month
month := (month < 10) ? (0 . month) : (month) ; 0 to 01
new_date := year . month
new_date += -1, days ; minus 1 day
return subStr(new_date, 7, 2)
}
/*
[script info]
description = find how many days are in a given month
author = davebrny
*/
@davebrny
Copy link
Author

days_in_month()
days_in_month(a_now)

days_in_month("201701")
days_in_month("20170123165500")

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