Created
May 9, 2019 15:00
-
-
Save wangeleile/4b3c86feb23d6273ebf03148849b1946 to your computer and use it in GitHub Desktop.
quarter ahk script
This file contains hidden or 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
q:: ;quarter - get start/end dates | |
vOutput := "" | |
vMonthFirst := 1 | |
;vMonthFirst := 3 | |
vYear := A_YYYY | |
;vYear := A_YYYY+1 | |
vOffset := 0 | |
Loop, 4 | |
vOutput .= JEE_QuarterGetStart(A_Index+vOffset, vMonthFirst, vYear) "-" | |
, vOutput .= JEE_QuarterGetEnd(A_Index+vOffset, vMonthFirst, vYear) "`r`n" | |
MsgBox, % vOutput | |
return | |
;note: vQuarter: an integer between 1 and 4 (or higher) | |
;note: vMonthFirst: an integer between 1 and 12 | |
JEE_QuarterGetStart(vQuarter, vMonthFirst:=1, vYear:="") | |
{ | |
local | |
if (vYear = "") | |
vYear := A_YYYY | |
vMonth := vMonthFirst+(vQuarter-1)*3 | |
if (vMonth < 1) | |
return | |
if (vMonth > 12) | |
vYear += (vMonth-1) // 12 | |
, vMonth := Mod(vMonth-1, 12)+1 | |
return vYear Format("{:02}", vMonth) "00000000" | |
} | |
;note: vQuarter: an integer between 1 and 4 (or higher) | |
;note: vMonthFirst: an integer between 1 and 12 | |
JEE_QuarterGetEnd(vQuarter, vMonthFirst:=1, vYear:="") | |
{ | |
local | |
if (vYear = "") | |
vYear := A_YYYY | |
vMonth := vMonthFirst+vQuarter*3 | |
if (vMonth < 1) | |
return | |
if (vMonth > 12) | |
vYear += (vMonth-1) // 12 | |
, vMonth := Mod(vMonth-1, 12)+1 | |
vDate := vYear Format("{:02}", vMonth) | |
return DateAdd(vDate, -1, "S") | |
} | |
/* | |
;commands as functions (AHK v2 functions for AHK v1) - AutoHotkey Community | |
;https://autohotkey.com/boards/viewtopic.php?f=37&t=29689 | |
DateAdd(DateTime, Time, TimeUnits) | |
{ | |
EnvAdd DateTime, %Time%, %TimeUnits% | |
return DateTime | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment