Last active
August 29, 2015 14:03
-
-
Save stevewithington/922c722707d0a4ac96ae to your computer and use it in GitHub Desktop.
ColdFusion / CFML : Get Week of Month (1-5)
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
<cfscript> | |
public any function getWeekOfMonth(date d='#Now()#', numeric minDaysInFirstWeek=1) { | |
var cal = CreateObject('java', 'java.util.GregorianCalendar').init( | |
JavaCast('int', Year(arguments.d)) | |
, JavaCast('int', Month(arguments.d)-1) | |
, JavaCast('int', Day(arguments.d)) | |
, JavaCast('int', Hour(arguments.d)) | |
, JavaCast('int', Minute(arguments.d)) | |
, JavaCast('int', Second(arguments.d)) | |
); | |
cal.setMinimalDaysInFirstWeek(arguments.minDaysInFirstWeek); | |
return cal.get(cal.WEEK_OF_MONTH); | |
} | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment