- Offizieller Beitrag
Ich dachte mir, ich könnte ja mal die Funktion "_DateDayOfWeek" etwas internationaler gestalten.
Hier also meine MultiLanguage-Version der Funktion:
Spoiler anzeigen
; Example Start
$sToday = _DateDayOfWeekML(@WDAY, 0, "0410") ; Italian
ConsoleWrite("Today (Italian) = " & $sToday & @CR)
$sToday = _DateDayOfWeekML(@WDAY, 0, "0407") ; German
ConsoleWrite("Today (German) = " & $sToday & @CR)
$sToday = _DateDayOfWeekML(@WDAY, 0, "0409") ; English
ConsoleWrite("Today (English) = " & $sToday & @CR)
$sToday = _DateDayOfWeekML(@WDAY, 0, "040c") ; French
ConsoleWrite("Today (French) = " & $sToday & @CR)
$sToday = _DateDayOfWeekML(@WDAY, 0, "0414") ; Norwegian
ConsoleWrite("Today (Norwegian) = " & $sToday & @CR)
$sToday = _DateDayOfWeekML(@WDAY, 1, @OSLang) ; @OSLang
ConsoleWrite("Today (@OSLang, Short) = " & $sToday & @CR)
; Example End
; #FUNCTION# ====================================================================================================================
; Name...........: _DateDayOfWeekML
; Description ...: Returns the name of the weekday, based on the specified day.
; Syntax.........: _DateDayOfWeek($iDayNum[, $fShort = 0][, $sLang = @OSLang])
; Parameters ....: $iDayNum - Day number (1 = Sunday, 7 = Saturday).
; $fShort - Format:
; |false - Long name of the weekday
; |true - Abbreviated name of the weekday
; $sLang - Language code, default = current local system date (@OSLang)
; Return values .: Success - Weekday name based on the specified language code
; Failure - A NULL string and sets @ERROR = 1
; Author ........: Oscar (http://www.autoit.de)
; Modified.......:
; Related .......: _DateDaysInMonth, _DateToDayOfWeek, _DateToDayOfWeekISO
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _DateDayOfWeekML($iDayNum, $fShort = False, $sLang = @OSLang)
If $iDayNum < 1 Or $iDayNum > 7 Then Return SetError(1, 0, '')
If $sLang Then $sLang = Dec($sLang)
Local $sFormat = StringLeft('dddd', 4 - Number($fShort = True))
Local $tDATE = DllStructCreate('word Year;word Month;word Dow;word Day;word Hour;word Minute;word Second;word MSeconds')
DllStructSetData($tDATE, 'Year', 2012) ; 2012/01/01 = Sunday, so $iDayNum perfect match
DllStructSetData($tDATE, 'Month', 1)
DllStructSetData($tDATE, 'Day', $iDayNum)
Local $Ret = DllCall('kernel32.dll', 'int', 'GetDateFormatW', 'ulong', $sLang, 'dword', 0, 'ptr', DllStructGetPtr($tDATE), 'wstr', $sFormat, 'wstr', '', 'int', 2048)
If @error Or Not $Ret[0] Then Return SetError(1, 0, '')
Return $Ret[5]
EndFunc ;==>_DateDayOfWeekML
Edit 21.09.2013 : Die Funktion basiert jetzt auf der Abfrage der "kernel32.dll". Somit stehen alle Sprachen zur Verfügung, die Windows anbietet.
Edit 23.09.2013 : Die Funktion auf das Wesentliche reduziert.