udfDayOfWeek
udfDayOfWeekJulian
int udfDayOfWeek (str)
int udfDayOfWeekJulian (str)
;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfDayOfWeekJulian (strYmdHms)
Return (5 + TimeJulianDay (strYmdHms)) mod 7
; The return value is an integer number in the range 0..6 = Sunday..Saturday.
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------

;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfDayOfWeek (strYmdHms)
intJulianDow = (5 + TimeJulianDay (strYmdHms)) mod 7
Return intJulianDow + (7 * !intJulianDow)
; The return value is an integer number in the range 1..7 = Monday..Sunday.
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------


; Test.

strYmdHms = "2009:02:01"
intDow1 = udfDayOfWeekJulian (strYmdHms) ; 0 = Sunday.
intDow2 = udfDayOfWeek (strYmdHms)       ; 7 = Sunday.


strListDayNames = "Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday"
strMsgTitle = "Demo: udfDayOfWeekJulian (strYmdHms)"
strMsgText = strYmdHms : @LF : @LF : "udfDayOfWeekJulian" : @LF : intDow1 : @TAB : ItemExtract (1 + intDow1, strListDayNames, ",")
strMsgText = strMsgText : @LF : @LF : "udfDayOfWeek" : @LF : intDow2 : @TAB : ItemExtract (1 + intDow2, strListDayNames, ",")
Message (strMsgTitle, strMsgText)


arrDayNames = Arrayize ("Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday", ",")
strMsgTitle = "Demo: udfDayOfWeekJulian (strYmdHms)"
strMsgText = strYmdHms : @LF : @LF : "udfDayOfWeekJulian" : @LF : intDow1 : @TAB : arrDayNames [intDow1]
strMsgText = strMsgText : @LF : @LF : "udfDayOfWeek" : @LF : intDow2 : @TAB : arrDayNames [intDow2]
Message (strMsgTitle, strMsgText)

Exit