argumentum Posted Friday at 03:34 PM Author Posted Friday at 03:34 PM 28 minutes ago, ioa747 said: because after the last change, from $sTempDate = StringReplace($sTempDate, "####", _DateToMonth($asDatePart[2], 0)) to $sTempDate = StringReplace($sTempDate, "####", _DateToMonth($asDatePart[2], $DMW_LOCALE_LONGNAME)) ..I was thinking of adding a 3rd parameter for system = 0 ( default ) / local = 1 29 minutes ago, ioa747 said: I get the long date from the regional settings (whereas I first got it in English, and it didn't matter) the month name has a different pronunciation than the 26th of the month As long as your language uses the same English alphabet symbols, I can figure it out. If is Arabic/Korean/etc., then I'd have a hard time understanding the OS in that language**. What language do you use @ioa747 ?, maybe I can run it on my side and look at it, have a better feeling for it. That is what I did with Portuguese to help a user in the forum, and later Spanish to corroborate/understand what's going on. I don't have time to run your code right now, but I'll look at it later at night. ** It would be a good project to OCR areas of the screen, translate them to the user language ( English for me ) and overly a label with the translation, so we can test more languages and know what to click. Maybe with AI doing the translation part ?. That'd be soooo cool 🤯 ( maybe something like that exists already but I don't know ) ioa747 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
ioa747 Posted Friday at 03:47 PM Posted Friday at 03:47 PM (edited) My language is Greek. Win10 22H2 with _DateTimeFormatEx_v2 e.g. the month is "Σεπτέμβριος" while the long date is "Παρασκευή, 26 Σεπτεμβρίου 2025" and now I get "Παρασκευή, 26 Σεπτέμβριος 2025" 3 hours ago, argumentum said: ..I was thinking of adding a 3rd parameter for system = 0 ( default ) / local = 1 _DateTimeFormatEx_vBeta4 🚀 Spoiler expandcollapse popup#include <Date.au3> #include <SQLite.au3> #include <Debug.au3> ;~ Input date in the format "YYYY/MM/DD[ HH:MM:SS [tt]]" ConsoleWrite("- " & _DateTimeFormatEx_vBeta4('2025/09/01 08:30:00 PM', 1) & @CRLF) ConsoleWrite("- " & _DateTimeFormatEx_vBeta4('2025/09/01 08:30:00 PM', 2) & @CRLF) ConsoleWrite("- " & _DateTimeFormatEx_vBeta4('2025/09/01 08:30:00 PM', 3) & @CRLF) ConsoleWrite("- " & _DateTimeFormatEx_vBeta4('2025/09/01 08:30:00 PM', 4) & @CRLF) ConsoleWrite("- " & _DateTimeFormatEx_vBeta4('2025/09/01 08:30:00 PM', 5) & @CRLF) ConsoleWrite("- " & _DateTimeFormatEx_vBeta4('2025/09/01 08:30:00 PM', 6) & @CRLF) ConsoleWrite("- " & _DateTimeFormatEx_vBeta4('2025/09/01 08:30:00 PM', 7) & @CRLF) ConsoleWrite("- " & _DateTimeFormatEx_vBeta4('2025/09/01 08:30:00 PM', "MMMM - yyyy|H:m") & @CRLF) ConsoleWrite("- " & _DateTimeFormatEx_vBeta4('2025/09/01 08:30:00 PM', "MMMM - yyyy|H:m", 1069) & @CRLF) ConsoleWrite("- " & _DateTimeFormatEx_vBeta4('2025/09/01 08:30:00 PM', "MMMM - yyyy|H:m", 1033) & @CRLF) ConsoleWrite("- " & _DateTimeFormatEx_vBeta4('2025/09/01 08:30:00 PM', "d MMMM yyyy", 1033) & @CRLF) ConsoleWrite("- " & _DateTimeFormatEx_vBeta4('2025/09/01 08:30:00 PM', "dddd d, MMMM yyyy|HH:mm:ss") & @CRLF) ConsoleWrite("- " & _DateTimeFormatEx_vBeta4('2025/09/01 08:30:00 PM', "yyyy.MM.dd|HH.mm.ss") & @CRLF) ConsoleWrite("- " & _DateTimeFormatEx_vBeta4('2025/09/01 08:30:00 PM', "|HH.mm.ss") & @CRLF) Func _DateTimeFormatEx_vBeta4($sDate, $vType, $iLcid = $LOCALE_USER_DEFAULT) Local $asDatePart[4], $asTimePart[4] Local $sTempDate = "", $sTempTime = "" Local $sAM, $sPM, $sTempString = "" ; Verify If InputDate is valid If Not _DateIsValid($sDate) Then Return SetError(1, 0, "") EndIf ; split the date and time into arrays _DateTimeSplit($sDate, $asDatePart, $asTimePart) If IsInt($vType) Then ; input validation If $vType < 0 Or $vType > 7 Then Return SetError(2, 0, "") EndIf Switch $vType Case 0 $sTempString = _WinAPI_GetLocaleInfo($iLcid, $LOCALE_SSHORTDATE) ; Get short date format. If Not @error And Not ($sTempString = '') Then $sTempDate = $sTempString Else $sTempDate = "M/d/yyyy" EndIf If $asTimePart[0] > 1 Then $sTempString = _WinAPI_GetLocaleInfo($iLcid, $LOCALE_STIMEFORMAT) ; Get short time format. If Not @error And Not ($sTempString = '') Then $sTempTime = $sTempString Else $sTempTime = "h:mm:ss tt" EndIf EndIf Case 1 $sTempString = _WinAPI_GetLocaleInfo($iLcid, $LOCALE_SLONGDATE) ; Get long date format. If Not @error And Not ($sTempString = '') Then $sTempDate = $sTempString Else $sTempDate = "dddd, MMMM dd, yyyy" EndIf Case 2 $sTempString = _WinAPI_GetLocaleInfo($iLcid, $LOCALE_SSHORTDATE) ; Get short date format. If Not @error And Not ($sTempString = '') Then $sTempDate = $sTempString Else $sTempDate = "M/d/yyyy" EndIf Case 3 If $asTimePart[0] > 1 Then $sTempString = _WinAPI_GetLocaleInfo($iLcid, $LOCALE_STIMEFORMAT) ; Get short time format. If Not @error And Not ($sTempString = '') Then $sTempTime = $sTempString Else $sTempTime = "h:mm:ss tt" EndIf EndIf Case 4 If $asTimePart[0] > 1 Then $sTempTime = "HH:mm" EndIf Case 5 If $asTimePart[0] > 1 Then $sTempTime = "HH:mm:ss" EndIf Case 6 If $asTimePart[0] > 1 Then $sTempTime = "hh:mm tt" EndIf Case 7 If $asTimePart[0] > 1 Then $sTempTime = "hh:mm:ss tt" EndIf EndSwitch Else Local $aPart = StringSplit($vType, "|") $sTempDate = $aPart[1] $sTempTime = "" If $aPart[0] = 2 Then $sTempTime = $aPart[2] EndIf If $asTimePart[0] > 1 Then $sTempString = _WinAPI_GetLocaleInfo($iLcid, $LOCALE_S1159) ; AM designator. If Not @error And Not ($sTempString = '') Then $sAM = $sTempString Else $sAM = "AM" EndIf $sTempString = _WinAPI_GetLocaleInfo($iLcid, $LOCALE_S2359) ; PM designator. If Not @error And Not ($sTempString = '') Then $sPM = $sTempString Else $sPM = "PM" EndIf If (StringInStr($sDate, 'pm') > 0) Or (StringInStr($sDate, $sPM) > 0) Then If $asTimePart[1] < 12 Then $asTimePart[1] += 12 ElseIf (StringInStr($sDate, 'am') > 0) Or (StringInStr($sDate, $sAM) > 0) Then If $asTimePart[1] = 12 Then $asTimePart[1] = 0 EndIf EndIf ; Encode a system time $tSystem = _Date_Time_EncodeSystemTime($asDatePart[2], $asDatePart[3], $asDatePart[1], $asTimePart[1], $asTimePart[2], $asTimePart[3]) Local $sResult = "" If $sTempDate <> "" Then $sResult &= _WinAPI_GetDateFormat($iLcid, $tSystem, 0, $sTempDate) EndIf If $sTempTime <> "" Then If $sResult <> "" Then $sResult &= " " $sResult &= _WinAPI_GetTimeFormat($iLcid, $tSystem, 0, $sTempTime) EndIf Return $sResult EndFunc ;==>_DateTimeFormatEx_vBeta4 Edited Friday at 07:14 PM by ioa747 corrections I know that I know nothing
argumentum Posted Friday at 11:32 PM Author Posted Friday at 11:32 PM (edited) ok: _DateTimeFormatEx_vBeta5 expandcollapse popup#Region ; *** Dynamically added Include files *** #include <DateTimeConstants.au3> ; added:09/27/25 02:33:59 #EndRegion ; *** Dynamically added Include files *** #include <Date.au3> #include <SQLite.au3> #include <Debug.au3> ; Show current date/time in the pc's format ConsoleWrite("- 1 >" & _DateTimeFormatEx_vBeta5('2025/09/01 08:30:00 PM', 1) & @CRLF) ConsoleWrite("- 2 >" & _DateTimeFormatEx_vBeta5('2025/09/01 08:30:00 PM', 2) & @CRLF) ConsoleWrite("- 3 >" & _DateTimeFormatEx_vBeta5('2025/09/01 08:30:00 PM', 3) & @CRLF) ConsoleWrite("- 3 >" & _DateTimeFormatEx_vBeta5('2025/09/01 08:30:00 PM', 4) & @CRLF) ConsoleWrite("- 5 >" & _DateTimeFormatEx_vBeta5('2025/09/01 08:30:00 PM', 5) & @CRLF) ConsoleWrite("- 6 >" & _DateTimeFormatEx_vBeta5('2025/09/01 08:30:00 PM', 6) & @CRLF) ConsoleWrite("- 7 >" & _DateTimeFormatEx_vBeta5('2025/09/01 08:30:00 PM', 7) & @CRLF) ConsoleWrite("- " & _DateTimeFormatEx_vBeta5('2025/09/01 08:30:00 PM', "MMMM - yyyy|H:m tt") & @CRLF) ConsoleWrite("- 1069 >" & _DateTimeFormatEx_vBeta5('2025/09/01 08:30:00 PM', "MMMM - yyyy|H:m tt", 1069) & "<" & @CRLF) ConsoleWrite("- 1033 >" & _DateTimeFormatEx_vBeta5('2025/09/01 08:30:00 PM', "MMMM - yyyy|H:m tt", 1033) & "<" & @CRLF) ConsoleWrite("- 1033 >" & _DateTimeFormatEx_vBeta5('2025/09/01 08:30:00 PM', "d MMMM yyyy", 1033) & "<" & @CRLF) ConsoleWrite("- " & _DateTimeFormatEx_vBeta5('2025/09/01 08:30:00 PM', "dddd d, MMMM yyyy|HH:mm:ss tt") & @CRLF) ; this "tt" is not applied =/ ??? ConsoleWrite("- " & _DateTimeFormatEx_vBeta5('2025/09/01 08:30:00 PM', "yyyy.MM.dd|HH.mm.ss tt") & @CRLF) ConsoleWrite("- " & _DateTimeFormatEx_vBeta5('2025/09/01 08:30:00 PM', "|HH.mm.ss tt") & @CRLF) Exit _DateTimeFormat_Compare() Func _DateTimeFormat_Compare() Local $aArray[10][8] $aArray[0][0] = " | 0 - date and/or time." $aArray[0][1] = " | 1 - long date, regional settings." $aArray[0][2] = " | 2 - short date, regional settings." $aArray[0][3] = " | 3 - time, regional settings." $aArray[0][4] = " | 4 - time 24-hour (hh:mm)." $aArray[0][5] = " | 5 - time 24-hour (hh:mm:ss)." $aArray[0][6] = " | 6 - time AM/PM (hh:mm tt)." $aArray[0][7] = " | 7 - time AM/PM (hh:mm:ss tt)." _DateTimeFormat_Test($aArray, _NowCalc(), @extended) _DateTimeFormat_Test($aArray, "2025/12/31 11:59:59", @extended) _DateTimeFormat_Test($aArray, "2025/12/31 23:59:59", @extended) _DateTimeFormat_Test($aArray, "2025/12/31 11:59:59 AM", @extended) _DateTimeFormat_Test($aArray, "2025/12/31 11:59:59 PM", @extended) ReDim $aArray[@extended + 1][8] Local $sArray = _SQLite_Display2DResult($aArray, 0, True) ConsoleWrite($sArray) ;~ ClipPut($sArray) ; to share in the forum if there is an error ;~ _DebugArrayDisplay($aArray, "_DateTimeFormat()") EndFunc ;==>_DateTimeFormat_Compare Func _DateTimeFormat_Test(ByRef $aArray, $sNowCalc, $iRow = 0) For $n = 0 To 7 $aArray[$iRow + 1][$n] = " | " & _DateTimeFormatEx_vBeta5($sNowCalc, $n) Next Return SetError(0, $iRow + 1, "Testing, testing. 1, 2, 3.") EndFunc ;==>_DateTimeFormat_Test Func _DateTimeFormatEx_vBeta5($sDate, $vType, $iLcid = $LOCALE_USER_DEFAULT) Local $asDatePart[4], $asTimePart[4] Local $sTempDate = "", $sTempTime = "" Local $sAM, $sPM, $sTempString = "" ; Verify If InputDate is valid If Not _DateIsValid($sDate) Then Return SetError(1, 0, "") EndIf ; input validation ; argumentum note: will need to think something out ;~ If $vType < 0 Or $vType > 7 Or Not IsInt($vType) Then ;~ Return SetError(2, 0, "") ;~ EndIf ; split the date and time into arrays _DateTimeSplit($sDate, $asDatePart, $asTimePart) Switch $vType Case 0 $sTempString = _WinAPI_GetLocaleInfo($LOCALE_USER_DEFAULT, $LOCALE_SSHORTDATE) ; Get short date format. If Not @error And Not ($sTempString = '') Then $sTempDate = $sTempString Else $sTempDate = "M/d/yyyy" EndIf If $asTimePart[0] > 1 Then $sTempString = _WinAPI_GetLocaleInfo($LOCALE_USER_DEFAULT, $LOCALE_STIMEFORMAT) ; Get short time format. If Not @error And Not ($sTempString = '') Then $sTempTime = $sTempString Else $sTempTime = "h:mm:ss tt" EndIf EndIf Case 1 $sTempString = _WinAPI_GetLocaleInfo($LOCALE_USER_DEFAULT, $LOCALE_SLONGDATE) ; Get long date format. If Not @error And Not ($sTempString = '') Then $sTempDate = $sTempString Else $sTempDate = "dddd, MMMM dd, yyyy" EndIf If StringInStr($sTempDate, "'") Then ; dddd, d' de 'MMMM' de 'yyyy Local $aArray = StringSplit($sTempDate, "'") ; deconstruct string $sTempDate = $aArray[1] For $n = 2 To UBound($aArray) - 2 Step 2 $sTempDate &= "' '" & $aArray[$n + 1] Next EndIf Case 2 $sTempString = _WinAPI_GetLocaleInfo($LOCALE_USER_DEFAULT, $LOCALE_SSHORTDATE) ; Get short date format. If Not @error And Not ($sTempString = '') Then $sTempDate = $sTempString Else $sTempDate = "M/d/yyyy" EndIf Case 3 If $asTimePart[0] > 1 Then $sTempString = _WinAPI_GetLocaleInfo($LOCALE_USER_DEFAULT, $LOCALE_STIMEFORMAT) ; Get short time format. If Not @error And Not ($sTempString = '') Then $sTempTime = $sTempString Else $sTempTime = "h:mm:ss tt" EndIf EndIf Case 4 If $asTimePart[0] > 1 Then $sTempTime = "hh:mm" EndIf Case 5 If $asTimePart[0] > 1 Then $sTempTime = "hh:mm:ss" EndIf Case 6 If $asTimePart[0] > 1 Then $sTempTime = "hh:mm tt" EndIf Case 7 If $asTimePart[0] > 1 Then $sTempTime = "hh:mm:ss tt" EndIf EndSwitch ; Format DATE ; argumentum note: kept for the "tt" not working otherwise If $sTempDate <> "" Then $sTempString = _WinAPI_GetLocaleInfo($LOCALE_USER_DEFAULT, $LOCALE_SDATE) ; Get short date format. If Not @error And Not ($sTempString = '') Then $sTempDate = StringReplace($sTempDate, "/", $sTempString) EndIf Local $iWday = _DateToDayOfWeek($asDatePart[1], $asDatePart[2], $asDatePart[3]) $asDatePart[3] = StringRight("0" & $asDatePart[3], 2) ; make sure the length is 2 $asDatePart[2] = StringRight("0" & $asDatePart[2], 2) ; make sure the length is 2 $sTempDate = StringReplace($sTempDate, "d", "@") $sTempDate = StringReplace($sTempDate, "m", "#") $sTempDate = StringReplace($sTempDate, "y", "&") Local $DMW_LONGNAME = 0; $DMW_LOCALE_LONGNAME(2) ; $DMW_LOCALE_USER (0) Local $DMW_SHORTNAME = 1; $DMW_LOCALE_SHORTNAME(3) ; $DMW_SHORTNAME (1) $sTempDate = StringReplace($sTempDate, "@@@@", _DateDayOfWeek($iWday, $DMW_LONGNAME)) $sTempDate = StringReplace($sTempDate, "@@@", _DateDayOfWeek($iWday, $DMW_LOCALE_SHORTNAME)) $sTempDate = StringReplace($sTempDate, "@@", $asDatePart[3]) $sTempDate = StringReplace($sTempDate, "@", StringReplace(StringLeft($asDatePart[3], 1), "0", "") & StringRight($asDatePart[3], 1)) $sTempDate = StringReplace($sTempDate, "####", _DateToMonth($asDatePart[2], $DMW_LONGNAME)) $sTempDate = StringReplace($sTempDate, "###", _DateToMonth($asDatePart[2], $DMW_LOCALE_SHORTNAME)) $sTempDate = StringReplace($sTempDate, "##", $asDatePart[2]) $sTempDate = StringReplace($sTempDate, "#", StringReplace(StringLeft($asDatePart[2], 1), "0", "") & StringRight($asDatePart[2], 1)) $sTempDate = StringReplace($sTempDate, "&&&&", $asDatePart[1]) $sTempDate = StringReplace($sTempDate, "&&", StringRight($asDatePart[1], 2)) EndIf ; Format TIME If $sTempTime <> "" Then $sTempString = _WinAPI_GetLocaleInfo($LOCALE_USER_DEFAULT, $LOCALE_S1159) ; AM designator. If Not @error And Not ($sTempString = '') Then $sAM = $sTempString Else $sAM = "AM" EndIf $sTempString = _WinAPI_GetLocaleInfo($LOCALE_USER_DEFAULT, $LOCALE_S2359) ; PM designator. If Not @error And Not ($sTempString = '') Then $sPM = $sTempString Else $sPM = "PM" EndIf $sTempString = _WinAPI_GetLocaleInfo($LOCALE_USER_DEFAULT, $LOCALE_STIME) ; Time seperator. If Not @error And Not ($sTempString = '') Then $sTempTime = StringReplace($sTempTime, ":", $sTempString) EndIf If (StringInStr($sDate, 'PM') > 0) Or (StringInStr($sDate, $sPM) > 0) Then ; AM/PM If $asTimePart[1] < 12 Then $asTimePart[1] += 12 ; AM/PM ElseIf (StringInStr($sDate, 'AM') > 0) Or (StringInStr($sDate, $sAM) > 0) Then ; AM/PM If $asTimePart[1] = 12 Then $asTimePart[1] = 0 ; AM/PM EndIf ; AM/PM If StringInStr($sTempTime, "tt") Then If $asTimePart[1] < 12 Then $sTempTime = StringReplace($sTempTime, "tt", $sAM) If $asTimePart[1] = 0 Then $asTimePart[1] = 12 Else $sTempTime = StringReplace($sTempTime, "tt", $sPM) If $asTimePart[1] > 12 Then $asTimePart[1] = $asTimePart[1] - 12 EndIf EndIf $asTimePart[1] = StringRight("0" & $asTimePart[1], 2) ; make sure the length is 2 $asTimePart[2] = StringRight("0" & $asTimePart[2], 2) ; make sure the length is 2 $asTimePart[3] = StringRight("0" & $asTimePart[3], 2) ; make sure the length is 2 $sTempTime = StringReplace($sTempTime, "hh", StringFormat("%02d", $asTimePart[1])) $sTempTime = StringReplace($sTempTime, "h", StringReplace(StringLeft($asTimePart[1], 1), "0", "") & StringRight($asTimePart[1], 1)) $sTempTime = StringReplace($sTempTime, "mm", StringFormat("%02d", $asTimePart[2])) $sTempTime = StringReplace($sTempTime, "ss", StringFormat("%02d", $asTimePart[3])) $sTempDate = StringStripWS($sTempDate & " " & $sTempTime, $STR_STRIPLEADING + $STR_STRIPTRAILING) EndIf If StringInStr($sTempDate, "'") Then ; dddd, d' de 'MMMM' de 'yyyy Local $aArray2 = StringSplit($sTempDate, "'") ; reconstruct string $sTempDate = $aArray2[1] For $n = 2 To UBound($aArray) - 2 Step 2 $sTempDate &= $aArray[$n] & $aArray2[$n + 1] Next EndIf If StringSplit($vType, "|") Then ; argumentum note: if it wasn't for backward compatibility, this is much shorter ; Encode a system time $tSystem = _Date_Time_EncodeSystemTime($asDatePart[2], $asDatePart[3], $asDatePart[1], $asTimePart[1], $asTimePart[2], $asTimePart[3]) Local $sResult = "" If $sTempDate <> "" Then $sResult &= _WinAPI_GetDateFormat($iLcid, $tSystem, 0, $sTempDate) EndIf If $sTempTime <> "" Then ; argumentum note: Some country settings do not have the concept of AM/PM If $sResult <> "" Then $sResult &= " " $sResult &= _WinAPI_GetTimeFormat($iLcid, $tSystem, 0, $sTempTime) EndIf EndIf Return $sTempDate EndFunc ;==>_DateTimeFormatEx_vBeta5 the reason is: "$sFormat [optional] The string that is used to form the time. For example, "hh:mm:ss tt". If this parameter is omitted or an empty string (Default), the function returns the string according to the time format for the specified locale. " If the locale does not have AM/PM and the user wants it, option 7 claims it'll do it, and we can not brake a promise 😇 English: Spoiler - 1 >Monday, September 1, 2025 - 2 >9/1/2025 - 3 >8:30:00 PM - 3 >20:30 - 5 >20:30:00 - 6 >08:30 PM - 7 >08:30:00 PM - 9/1/2025 8:30:00 PM - 1069 >9/1/2025 8:30:00 PM< - 1033 >9/1/2025 8:30:00 PM< - 1033 >9/1/2025 8:30:00 PM< - 9/1/2025 8:30:00 PM - 9/1/2025 8:30:00 PM - 9/1/2025 8:30:00 PM Spanish: Spoiler - 1 >lunes, 1 de septiembre de 2025 - 2 >01/09/2025 - 3 >20:30:00 - 3 >20:30 - 5 >20:30:00 - 6 >08:30 PM - 7 >08:30:00 PM - 01/09/2025 20:30:00 - 1069 >01/09/2025 20:30:00< - 1033 >01/09/2025 20:30:00< - 1033 >01/09/2025 20:30:00< - 01/09/2025 20:30:00 - 01/09/2025 20:30:00 - 01/09/2025 20:30:00 So English has AM/PM, Spanish doesn't. Do you find this beta5 a good compromise or you feel you can fix it differently ? Also, test it in Greek, ( Greek is like, Greek Chinese to me ) Edit: , I left the "$DMW_LOCALE_LONGNAME" there, ..about to eat now. I'll test later Edit 2: done. Edit 3: Local $DMW_LONGNAME = 2 ; $DMW_LOCALE_LONGNAME(2) ; $DMW_LOCALE_USER (0) Local $DMW_SHORTNAME = 3 ; $DMW_LOCALE_SHORTNAME(3) ; $DMW_SHORTNAME (1) only with the 2 & 3 is that I get the proper idiom's string. Edited yesterday at 12:44 AM by argumentum more Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
argumentum Posted yesterday at 02:23 AM Author Posted yesterday at 02:23 AM (edited) Ok. Installed the Greek version. Is this what you see in the editor ? How do I fix that ? Ok, that was SciTE-Light, this is the full version: Edited yesterday at 02:33 AM by argumentum Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
ioa747 Posted yesterday at 02:48 AM Posted yesterday at 02:48 AM (edited) I solved such problems by putting Greek here, and checking it, for UTF https://www.autoitscript.com/forum/topic/212666-perhaps-output-encoding-error-in-au3checkexe/#comment-1540626 Edited yesterday at 02:48 AM by ioa747 argumentum 1 I know that I know nothing
argumentum Posted yesterday at 02:58 AM Author Posted yesterday at 02:58 AM For what I see, the coma is meant to be there 🤷♂️ Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
argumentum Posted yesterday at 03:12 AM Author Posted yesterday at 03:12 AM 22 minutes ago, ioa747 said: I solved such problems by putting Greek here, and checking it, for UTF https://www.autoitscript.com/forum/topic/212666-perhaps-output-encoding-error-in-au3checkexe/#comment-1540626 ...any command line to get there ?. Can't find it in any language VMs. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
ioa747 Posted yesterday at 03:14 AM Posted yesterday at 03:14 AM I don't know 😟 I know that I know nothing
argumentum Posted yesterday at 03:15 AM Author Posted yesterday at 03:15 AM Win+R -> intl.cpl Administrative tab Click the Change system locale button. Enable Beta: Use Unicode UTF-8 for worldwide language support Reboot Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
argumentum Posted yesterday at 03:27 AM Author Posted yesterday at 03:27 AM ..back to the scheduled program... Do you wanna tweak the beta5 ? ( to force an AM/PM if not in the idiom's settings in your strings (h:m tt) ? ) In any case, all these options will be declared in the help file. If this is as far as we take it, the explanation will be in the help file. Would you like to add "yyyy.MM.dd|HH.mm.ss tt|AM/PM" ? "The ball is in your court" Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
ioa747 Posted 18 hours ago Posted 18 hours ago (edited) ⚽ _DateTimeFormatEx_vBeta4a Spoiler expandcollapse popup; https://www.autoitscript.com/forum/topic/213061-hour-ampm-yes-one-more-of-these/#findComment-1546257 #include <Date.au3> #include <SQLite.au3> #include <Debug.au3> ;~ # What the notations mean # ;~ Date: ;~ d, dd = day; ddd, dddd = day of week; M= month; y = year ;~ Time: ;~ h= hour m= minute ;~ s = second (long time only) ;~ tt= AM. or P.M. ;~ h/H = 12/24 hour ;~ hh, mm, ss = display leading zero ;~ h, m, s = do not display leading zero ;~ # What the notations mean # ;~ LangCodes ;~ https://ss64.com/tools/locale.html ;~ English (Europe) => 4096 => $LOCALE_CUSTOM_UNSPECIFIED ;~ German (Germany) => 1031 ;~ Greek (Greece) => 1032 ;~ English (United States) => 1033 ;~ Spanish (Spain) => 3082 ;~ Esperanto (World) => 4096 => $LOCALE_CUSTOM_UNSPECIFIED ; The locale identifier (LCID) that specifies the locale or one of the following predefined values. ConsoleWrite("$LOCALE_INVARIANT=" & $LOCALE_INVARIANT & @CRLF) ConsoleWrite("$LOCALE_SYSTEM_DEFAULT=" & $LOCALE_SYSTEM_DEFAULT & @CRLF) ConsoleWrite("$LOCALE_USER_DEFAULT=" & $LOCALE_USER_DEFAULT & @CRLF) ; Windows Vista or later ConsoleWrite("$LOCALE_CUSTOM_DEFAULT=" & $LOCALE_CUSTOM_DEFAULT & @CRLF) ConsoleWrite("$LOCALE_CUSTOM_UI_DEFAULT=" & $LOCALE_CUSTOM_UI_DEFAULT & @CRLF) ConsoleWrite("$LOCALE_CUSTOM_UNSPECIFIED=" & $LOCALE_CUSTOM_UNSPECIFIED & @CRLF) ConsoleWrite("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" & @CRLF) ;~ ConsoleWrite("- 1031 >" & _DateTimeFormatEx_vBeta4a('2025/12/30 08:30:00 PM', "dddd, d. MMMM yyyy", 1031) & "<" & @CRLF) ;~ ConsoleWrite("- 1031 >" & _DateTimeFormatEx_vBeta4a('2025/12/30 08:30:00 PM', "dddd d,|h:m tt", 1031) & "<" & @CRLF) ;~ ConsoleWrite("- 1031 >" & _DateTimeFormatEx_vBeta4a('2025/12/30 08:30:00 PM', "d MMMM yyyy", 1031) & "<" & @CRLF) ;~ ConsoleWrite("- 1032 >" & _DateTimeFormatEx_vBeta4a('2025/12/30 08:30:00 PM', "dddd, d MMMM yyyy", 1032) & "<" & @CRLF) ;~ ConsoleWrite("- 1032 >" & _DateTimeFormatEx_vBeta4a('2025/12/30 08:30:00 PM', "dddd d,|h:m tt", 1032) & "<" & @CRLF) ;~ ConsoleWrite("- 1032 >" & _DateTimeFormatEx_vBeta4a('2025/12/30 08:30:00 PM', "d MMMM yyyy", 1032) & "<" & @CRLF) ;~ ConsoleWrite("- 1033 >" & _DateTimeFormatEx_vBeta4a('2025/12/30 08:30:00 PM', "dddd, MMMM d, yyyy", 1033) & "<" & @CRLF) ;~ ConsoleWrite("- 1033 >" & _DateTimeFormatEx_vBeta4a('2025/12/30 08:30:00 PM', "dddd d,|h:m tt", 1033) & "<" & @CRLF) ;~ ConsoleWrite("- 1033 >" & _DateTimeFormatEx_vBeta4a('2025/12/30 08:30:00 PM', "d MMMM yyyy", 1033) & "<" & @CRLF) ;~ ConsoleWrite("- 3082 >" & _DateTimeFormatEx_vBeta4a('2025/12/30 08:30:00 PM', "dddd, d' de 'MMMM' de 'yyyy", 3082) & "<" & @CRLF) ;~ ConsoleWrite("- 3082 >" & _DateTimeFormatEx_vBeta4a('2025/12/30 08:30:00 PM', "dddd d,|h:m tt", 3082) & "<" & @CRLF) ;~ ConsoleWrite("- 3082 >" & _DateTimeFormatEx_vBeta4a('2025/12/30 08:30:00 PM', "d MMMM yyyy", 3082) & "<" & @CRLF) ;~ ;~ ConsoleWrite("- " & _DateTimeFormatEx_vBeta4a('2025/09/01 08:30:00 PM', "yyyy_MM_dd|HH_mm_ss") & @CRLF) ;~ ConsoleWrite("- " & _DateTimeFormatEx_vBeta4a('2025/09/01 08:30:00 PM', "|hh.mm.ss tt") & @CRLF) ;~ ConsoleWrite("- " & _DateTimeFormatEx_vBeta4a('2025/09/01 08:30:00 PM', "|HH.mm.ss") & @CRLF) ;~ ConsoleWrite("- " & _DateTimeFormatEx_vBeta4a('2025/09/01 08:30:00 PM', "|H.m") & @CRLF) ;~ ConsoleWrite("- " & _DateTimeFormatEx_vBeta4a('2025/09/01 08:30:00 PM', "|h.m tt") & @CRLF) Exit _DateTimeFormat_Compare() Func _DateTimeFormat_Compare() Local $aArray[10][8] $aArray[0][0] = " | 0 - date and/or time." $aArray[0][1] = " | 1 - long date, regional settings." $aArray[0][2] = " | 2 - short date, regional settings." $aArray[0][3] = " | 3 - time, regional settings." $aArray[0][4] = " | 4 - time 24-hour (hh:mm)." $aArray[0][5] = " | 5 - time 24-hour (hh:mm:ss)." $aArray[0][6] = " | 6 - time AM/PM (hh:mm tt)." $aArray[0][7] = " | 7 - time AM/PM (hh:mm:ss tt)." _DateTimeFormat_Test($aArray, _NowCalc(), @extended) _DateTimeFormat_Test($aArray, "2025/12/31 11:59:59", @extended) _DateTimeFormat_Test($aArray, "2025/12/31 23:59:59", @extended) _DateTimeFormat_Test($aArray, "2025/12/31 11:59:59 AM", @extended) _DateTimeFormat_Test($aArray, "2025/12/31 11:59:59 PM", @extended) ReDim $aArray[@extended + 1][8] Local $sArray = _SQLite_Display2DResult($aArray, 0, True) ConsoleWrite($sArray) ;~ ClipPut($sArray) ; to share in the forum if there is an error ;~ _DebugArrayDisplay($aArray, "_DateTimeFormat()") EndFunc ;==>_DateTimeFormat_Compare Func _DateTimeFormat_Test(ByRef $aArray, $sNowCalc, $iRow = 0) For $n = 0 To 7 $aArray[$iRow + 1][$n] = " | " & _DateTimeFormatEx_vBeta4a($sNowCalc, $n) Next Return SetError(0, $iRow + 1, "Testing, testing. 1, 2, 3.") EndFunc ;==>_DateTimeFormat_Test Func _DateTimeFormatEx_vBeta4a($sDate, $vType, $iLcid = $LOCALE_USER_DEFAULT) Local $asDatePart[4], $asTimePart[4] Local $sTempDate = "", $sTempTime = "" Local $sAM, $sPM, $sTempString = "" ; Verify If InputDate is valid If Not _DateIsValid($sDate) Then Return SetError(1, 0, "") EndIf ; split the date and time into arrays _DateTimeSplit($sDate, $asDatePart, $asTimePart) If IsInt($vType) Then ; input validation If $vType < 0 Or $vType > 7 Then Return SetError(2, 0, "") EndIf Switch $vType Case 0 $sTempString = _WinAPI_GetLocaleInfo($iLcid, $LOCALE_SSHORTDATE) ; Get short date format. If Not @error And Not ($sTempString = '') Then $sTempDate = $sTempString Else $sTempDate = "M/d/yyyy" EndIf If $asTimePart[0] > 1 Then $sTempString = _WinAPI_GetLocaleInfo($iLcid, $LOCALE_STIMEFORMAT) ; Get short time format. If Not @error And Not ($sTempString = '') Then $sTempTime = $sTempString Else $sTempTime = "h:mm:ss tt" EndIf EndIf Case 1 $sTempString = _WinAPI_GetLocaleInfo($iLcid, $LOCALE_SLONGDATE) ; Get long date format. If Not @error And Not ($sTempString = '') Then $sTempDate = $sTempString Else $sTempDate = "dddd, MMMM dd, yyyy" EndIf Case 2 $sTempString = _WinAPI_GetLocaleInfo($iLcid, $LOCALE_SSHORTDATE) ; Get short date format. If Not @error And Not ($sTempString = '') Then $sTempDate = $sTempString Else $sTempDate = "M/d/yyyy" EndIf Case 3 If $asTimePart[0] > 1 Then $sTempString = _WinAPI_GetLocaleInfo($iLcid, $LOCALE_STIMEFORMAT) ; Get short time format. If Not @error And Not ($sTempString = '') Then $sTempTime = $sTempString Else $sTempTime = "h:mm:ss tt" EndIf EndIf Case 4 If $asTimePart[0] > 1 Then $sTempTime = "HH:mm" EndIf Case 5 If $asTimePart[0] > 1 Then $sTempTime = "HH:mm:ss" EndIf Case 6 If $asTimePart[0] > 1 Then $sTempTime = "hh:mm tt" EndIf Case 7 If $asTimePart[0] > 1 Then $sTempTime = "hh:mm:ss tt" EndIf EndSwitch Else Local $aPart = StringSplit($vType, "|") $sTempDate = $aPart[1] $sTempTime = "" If $aPart[0] = 2 Then $sTempTime = $aPart[2] EndIf If $asTimePart[0] > 1 Then $sTempString = _WinAPI_GetLocaleInfo($iLcid, $LOCALE_S1159) ; AM designator. If Not @error And Not ($sTempString = '') Then $sAM = $sTempString Else $sAM = "AM" EndIf $sTempString = _WinAPI_GetLocaleInfo($iLcid, $LOCALE_S2359) ; PM designator. If Not @error And Not ($sTempString = '') Then $sPM = $sTempString Else $sPM = "PM" EndIf If (StringInStr($sDate, 'pm') > 0) Or (StringInStr($sDate, $sPM) > 0) Then If $asTimePart[1] < 12 Then $asTimePart[1] += 12 ElseIf (StringInStr($sDate, 'am') > 0) Or (StringInStr($sDate, $sAM) > 0) Then If $asTimePart[1] = 12 Then $asTimePart[1] = 0 EndIf EndIf ; Encode a system time $tSystem = _Date_Time_EncodeSystemTime($asDatePart[2], $asDatePart[3], $asDatePart[1], $asTimePart[1], $asTimePart[2], $asTimePart[3]) Local $sfinalTime = _WinAPI_GetTimeFormat($iLcid, $tSystem, 0, $sTempTime) ; force AM/PM if regional settings not have it If StringInStr($sTempTime, "tt") Then If (StringInStr($sfinalTime, 'pm') = 0) And (StringInStr($sfinalTime, $sPM) = 0) And _ (StringInStr($sfinalTime, 'am') = 0) And (StringInStr($sfinalTime, $sAM) = 0) And _ (StringInStr($sTempTime, "H", 1) = 0) Then If $asTimePart[1] < 12 Then $sfinalTime &= " " & $sAM Else $sfinalTime &= " " & $sPM EndIf EndIf EndIf Local $sResult = "" If $sTempDate <> "" Then $sResult &= _WinAPI_GetDateFormat($iLcid, $tSystem, 0, $sTempDate) EndIf If $sTempTime <> "" Then If $sResult <> "" Then $sResult &= " " $sResult &= $sfinalTime ; _WinAPI_GetTimeFormat($iLcid, $tSystem, 0, $sTempTime) EndIf Return $sResult EndFunc ;==>_DateTimeFormatEx_vBeta4a Edited 18 hours ago by ioa747 argumentum 1 I know that I know nothing
argumentum Posted 16 hours ago Author Posted 16 hours ago ..was looking at Hour, Minute, and Second Format Pictures - Win32 apps | Microsoft Learn and say: "t One-character time marker string. Note: This format is not recommended for use with certain languages, such as Japanese (Japan). With this format, an application always takes the first character from the time marker string, defined by LOCALE_S1159 (AM) and LOCALE_S2359 (PM). Because of this, the application can create incorrect formatting with the same string used for both AM and PM." So, adding a custom "AM/PM" would not be that much more code/work and would give the user the ability to use "a/p" if that's the user's fancy, or just makes sense in that culture. Will you add it ? Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
ioa747 Posted 16 hours ago Posted 16 hours ago I'm not sure I understand, but using my imagination, ... you mean that we need to put a new parameter for $sAmPm like you did in HourAmPm($sDateTime, $sAmPm = Default, $iTrimRight = Default, $iNoDate = Default); in case the user wants a personal AM/PM and the regional settings do not have it like _DateTimeFormatEx_vBeta4a($sDate, $vType, $sAmPm = "AM/PM", $iLcid = $LOCALE_USER_DEFAULT) I know that I know nothing
argumentum Posted 15 hours ago Author Posted 15 hours ago (edited) "dddd d,|h:m tt|AM|PM" Just expand the string to include custom "ante meridiem" and "post meridiem" strings. So "dddd d,|h:m tt| in the morning| in the evening" could be had. Going the extra mile, not separate the date and time but have it mixed: "dddd, d' de 'MMMM' de 'yyyy' a las 'hh:mm tt|am|pm" and that would be more flexible to use for those that don't like anything from 0 to 7 Edited 14 hours ago by argumentum Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
ioa747 Posted 14 hours ago Posted 14 hours ago When we have case 6 or 7, and there is no AM/PM in the regional settings, what will be used for AM/PM? I know that I know nothing
ioa747 Posted 14 hours ago Posted 14 hours ago (edited) _DateTimeFormatEx_vBeta4b Spoiler expandcollapse popup; https://www.autoitscript.com/forum/topic/213061-hour-ampm-yes-one-more-of-these/#findComment-1546257 #include <Date.au3> #include <SQLite.au3> #include <Debug.au3> ;~ # What the notations mean # ;~ Date: ;~ d, dd = day; ddd, dddd = day of week; M= month; y = year ;~ Time: ;~ h= hour m= minute ;~ s = second (long time only) ;~ tt= AM. or P.M. ;~ h/H = 12/24 hour ;~ hh, mm, ss = display leading zero ;~ h, m, s = do not display leading zero ;~ # What the notations mean # ;~ LangCodes ;~ https://ss64.com/tools/locale.html ConsoleWrite("- " & _DateTimeFormatEx_vBeta4b('2025/09/01 08:30:22 PM', "yyyy_MM_dd|_HH_mm_ss") & @CRLF) ConsoleWrite("- " & _DateTimeFormatEx_vBeta4b('2025/09/01 08:30:22 PM', "yyyy_MM_dd| HH:mm tt", 1033, "a|p") & @CRLF) ConsoleWrite("- 1031 >" & _DateTimeFormatEx_vBeta4b('2025/12/30 08:30:00 PM', "dddd, d. MMMM yyyy, |h:m tt", 1031, "🌝|🌜") & @CRLF) ;~ Exit _DateTimeFormat_Compare() Func _DateTimeFormat_Compare() Local $aArray[10][8] $aArray[0][0] = " | 0 - date and/or time." $aArray[0][1] = " | 1 - long date, regional settings." $aArray[0][2] = " | 2 - short date, regional settings." $aArray[0][3] = " | 3 - time, regional settings." $aArray[0][4] = " | 4 - time 24-hour (hh:mm)." $aArray[0][5] = " | 5 - time 24-hour (hh:mm:ss)." $aArray[0][6] = " | 6 - time AM/PM (hh:mm tt)." $aArray[0][7] = " | 7 - time AM/PM (hh:mm:ss tt)." _DateTimeFormat_Test($aArray, _NowCalc(), @extended) _DateTimeFormat_Test($aArray, "2025/12/31 11:59:59", @extended) _DateTimeFormat_Test($aArray, "2025/12/31 23:59:59", @extended) _DateTimeFormat_Test($aArray, "2025/12/31 11:59:59 AM", @extended) _DateTimeFormat_Test($aArray, "2025/12/31 11:59:59 PM", @extended) ReDim $aArray[@extended + 1][8] Local $sArray = _SQLite_Display2DResult($aArray, 0, True) ConsoleWrite($sArray) ;~ ClipPut($sArray) ; to share in the forum if there is an error ;~ _DebugArrayDisplay($aArray, "_DateTimeFormat()") EndFunc ;==>_DateTimeFormat_Compare Func _DateTimeFormat_Test(ByRef $aArray, $sNowCalc, $iRow = 0) For $n = 0 To 7 $aArray[$iRow + 1][$n] = " | " & _DateTimeFormatEx_vBeta4b($sNowCalc, $n) Next Return SetError(0, $iRow + 1, "Testing, testing. 1, 2, 3.") EndFunc ;==>_DateTimeFormat_Test Func _DateTimeFormatEx_vBeta4b($sDate, $vType, $iLcid = $LOCALE_USER_DEFAULT, $sAmPm = Default) Local $asDatePart[4], $asTimePart[4] Local $sTempDate = "", $sTempTime = "" Local $sAM, $sPM, $sTempString = "" ; Verify If InputDate is valid If Not _DateIsValid($sDate) Then Return SetError(1, 0, "") EndIf ; split the date and time into arrays _DateTimeSplit($sDate, $asDatePart, $asTimePart) If IsInt($vType) Then ; input validation If $vType < 0 Or $vType > 7 Then Return SetError(2, 0, "") EndIf Switch $vType Case 0 $sTempString = _WinAPI_GetLocaleInfo($iLcid, $LOCALE_SSHORTDATE) ; Get short date format. If Not @error And Not ($sTempString = '') Then $sTempDate = $sTempString Else $sTempDate = "M/d/yyyy" EndIf If $asTimePart[0] > 1 Then $sTempString = _WinAPI_GetLocaleInfo($iLcid, $LOCALE_STIMEFORMAT) ; Get short time format. If Not @error And Not ($sTempString = '') Then $sTempTime = $sTempString Else $sTempTime = "h:mm:ss tt" EndIf EndIf Case 1 $sTempString = _WinAPI_GetLocaleInfo($iLcid, $LOCALE_SLONGDATE) ; Get long date format. If Not @error And Not ($sTempString = '') Then $sTempDate = $sTempString Else $sTempDate = "dddd, MMMM dd, yyyy" EndIf Case 2 $sTempString = _WinAPI_GetLocaleInfo($iLcid, $LOCALE_SSHORTDATE) ; Get short date format. If Not @error And Not ($sTempString = '') Then $sTempDate = $sTempString Else $sTempDate = "M/d/yyyy" EndIf Case 3 If $asTimePart[0] > 1 Then $sTempString = _WinAPI_GetLocaleInfo($iLcid, $LOCALE_STIMEFORMAT) ; Get short time format. If Not @error And Not ($sTempString = '') Then $sTempTime = $sTempString Else $sTempTime = "h:mm:ss tt" EndIf EndIf Case 4 If $asTimePart[0] > 1 Then $sTempTime = "HH:mm" EndIf Case 5 If $asTimePart[0] > 1 Then $sTempTime = "HH:mm:ss" EndIf Case 6 If $asTimePart[0] > 1 Then $sTempTime = "hh:mm tt" EndIf Case 7 If $asTimePart[0] > 1 Then $sTempTime = "hh:mm:ss tt" EndIf EndSwitch $sTempTime = " " & $sTempTime Else Local $aPart = StringSplit($vType, "|") $sTempDate = $aPart[1] $sTempTime = "" If $aPart[0] = 2 Then $sTempTime = $aPart[2] EndIf If $asTimePart[0] > 1 Then $sTempString = _WinAPI_GetLocaleInfo($iLcid, $LOCALE_S1159) ; AM designator. If Not @error And Not ($sTempString = '') Then $sAM = $sTempString Else $sAM = "AM" EndIf $sTempString = _WinAPI_GetLocaleInfo($iLcid, $LOCALE_S2359) ; PM designator. If Not @error And Not ($sTempString = '') Then $sPM = $sTempString Else $sPM = "PM" EndIf If (StringInStr($sDate, 'pm') > 0) Or (StringInStr($sDate, $sPM) > 0) Then If $asTimePart[1] < 12 Then $asTimePart[1] += 12 ElseIf (StringInStr($sDate, 'am') > 0) Or (StringInStr($sDate, $sAM) > 0) Then If $asTimePart[1] = 12 Then $asTimePart[1] = 0 EndIf EndIf ; Encode a system time $tSystem = _Date_Time_EncodeSystemTime($asDatePart[2], $asDatePart[3], $asDatePart[1], $asTimePart[1], $asTimePart[2], $asTimePart[3]) Local $sfinalTime = _WinAPI_GetTimeFormat($iLcid, $tSystem, 0, $sTempTime) ; force AM/PM if regional settings not have it If StringInStr($sTempTime, "tt") Then If (StringInStr($sfinalTime, 'pm') = 0) And (StringInStr($sfinalTime, $sPM) = 0) And _ (StringInStr($sfinalTime, 'am') = 0) And (StringInStr($sfinalTime, $sAM) = 0) And _ (StringInStr($sTempTime, "H", 1) = 0) Then If $asTimePart[1] < 12 Then $sfinalTime &= " " & $sAM Else $sfinalTime &= " " & $sPM EndIf EndIf ; replace $aAmPm if defined If $sAmPm <> Default Then Local $aAmPm = StringSplit($sAmPm, "|", 2) If UBound($aAmPm) < 2 Then ConsoleWrite("oo|ps" & @CRLF) $sfinalTime = StringReplace($sfinalTime, 'am', $aAmPm[0]) $sfinalTime = StringReplace($sfinalTime, $sAM, $aAmPm[0]) $sfinalTime = StringReplace($sfinalTime, 'pm', $aAmPm[1]) $sfinalTime = StringReplace($sfinalTime, $sPM, $aAmPm[1]) EndIf EndIf Local $sResult = "" If $sTempDate <> "" Then $sResult &= _WinAPI_GetDateFormat($iLcid, $tSystem, 0, $sTempDate) If $sTempTime <> "" And $sTempTime <> " " Then $sResult &= $sfinalTime Return $sResult EndFunc ;==>_DateTimeFormatEx_vBeta4b Edited 13 hours ago by ioa747 I know that I know nothing
argumentum Posted 12 hours ago Author Posted 12 hours ago 2 hours ago, ioa747 said: When we have case 6 or 7, and there is no AM/PM in the regional settings, what will be used for AM/PM? "||AM|PM" or forcefully add the default ( AM|PM ). But the merging of date and time would attend to those that have a regional setting that does not please the user. In you case that coma before the year. Like a free style option 1 ... Case 1 $sTempString = _WinAPI_GetLocaleInfo($iLcid, $LOCALE_SLONGDATE) ; Get long date format. If Not @error And Not ($sTempString = '') Then $sTempDate = $sTempString ConsoleWrite('+ ' & $sTempDate & @CRLF) Else $sTempDate = "dddd, MMMM dd, yyyy" ConsoleWrite('! ' & $sTempDate & @CRLF) EndIf ... that would include ... $sTempString = _WinAPI_GetLocaleInfo($iLcid, $LOCALE_STIMEFORMAT) ; Get short time format. If Not @error And Not ($sTempString = '') Then $sTempTime = $sTempString Else $sTempTime = "h:mm:ss tt" EndIf ... that way the user can make any time/date possibility without having to call it twice. I'd explain it in code but I've got a headache - That's what she said Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
ioa747 Posted 6 hours ago Posted 6 hours ago I will try to explain my problem better to you. if I execute the following ConsoleWrite("- " & _DateTimeFormatEx_vBeta4b('2025/09/01 08:30:22 PM', "dddd, d MMMM yyyy", 1032) & @CRLF) ConsoleWrite("- " & _DateTimeFormatEx_vBeta4b('2025/09/01 08:30:22 PM', "d MMMM", 1032) & @CRLF) ConsoleWrite("- " & _DateTimeFormatEx_vBeta4b('2025/09/01 08:30:22 PM', "MMMM", 1032) & @CRLF) I will take - Δευτέρα, 1 Σεπτεμβρίου 2025 - 1 Σεπτεμβρίου - Σεπτέμβριος As you can see in the example, the month's pronunciation is different when I call the month with a number in front, e.g. "1 September" , and differently when I call just the month "September" and this cannot change, if internally the function breaks "1 September", and takes separately "1" and separately "September" , and gives me "1" & " " & "September" $sTempDate = StringReplace($sTempDate, "@@", $asDatePart[3]) $sTempDate = StringReplace($sTempDate, "####", _DateToMonth($asDatePart[2], $DMW_LOCALE_LONGNAME)) I know that I know nothing
ioa747 Posted 5 hours ago Posted 5 hours ago What you describe above could be done, with this way. ; ### Date/Time Formatting Flags (DTF) ### ; Date Flags (Only ONE of these should be set) Global Const $DTF_LONGDATE = 1 ; Long Date (e.g., Sunday, September 1, 2025) Global Const $DTF_SHORTDATE = 2 ; Short Date (e.g., 9/1/2025 or 01/09/2025) ; Time Flags (Only ONE of these should be set) Global Const $DTF_SHORTTIME = 4 ; Short Time (Locale Default - e.g., 8:30:22 AM) Global Const $DTF_TIME_HHMM_24 = 8 ; Time only (e.g., 08:30 - 24hr) Global Const $DTF_TIME_HHMMSS_24 = 16 ; Time only (e.g., 08:30:22 - 24hr) Global Const $DTF_TIME_HHMM_12 = 32 ; Time only (e.g., 08:30 AM - 12hr) Global Const $DTF_TIME_HHSSTT_12 = 64 ; Time only (e.g., 08:30:22 AM - 12hr) ; Combination for Date+Time (Old $sType=0 equivalent) Global Const $DTF_DEFAULT = $DTF_SHORTDATE + $DTF_SHORTTIME ; Use Short Date + Short Time ConsoleWrite("- " & _DateTimeFormat('2025/09/01 08:30:22 PM', 1 ) & @CRLF) ConsoleWrite("- " & _DateTimeFormat('2025/09/01 08:30:22 PM', 1 + 64) & @CRLF) ConsoleWrite("- " & _DateTimeFormat('2025/09/01 08:30:22 PM', 2 + 4 ) & @CRLF) but it breaks backward compatibility. I know that I know nothing
ioa747 Posted 5 hours ago Posted 5 hours ago I liked _DateTimeFormatEx_vBeta4a the most, with a small modification that I made, so that it can return the format as a single string without a space between the date and time if the user wants it. like 2025_09_01_20_30_00 which covers the case where the user makes a selection with AM|PM, and it does not exist in the regional settings, it sets the classic AM|PM _DateTimeFormatEx_vBeta4a Spoiler expandcollapse popup; https://www.autoitscript.com/forum/topic/213061-hour-ampm-yes-one-more-of-these/#findComment-1546257 #include <Date.au3> #include <SQLite.au3> #include <Debug.au3> ;~ # What the notations mean # ;~ Date: ;~ d, dd = day; ddd, dddd = day of week; M= month; y = year ;~ Time: ;~ h= hour m= minute ;~ s = second (long time only) ;~ tt= AM. or P.M. ;~ h/H = 12/24 hour ;~ hh, mm, ss = display leading zero ;~ h, m, s = do not display leading zero ;~ # What the notations mean # ;~ LangCodes ;~ https://ss64.com/tools/locale.html ;~ English (Europe) => 4096 => $LOCALE_CUSTOM_UNSPECIFIED ;~ German (Germany) => 1031 ;~ Greek (Greece) => 1032 ;~ English (United States) => 1033 ;~ Spanish (Spain) => 3082 ;~ Esperanto (World) => 4096 => $LOCALE_CUSTOM_UNSPECIFIED ;~ ConsoleWrite("- 1031 >" & _DateTimeFormatEx_vBeta4a('2025/12/30 08:30:00 PM', "dddd, d. MMMM yyyy", 1031) & "<" & @CRLF) ;~ ConsoleWrite("- 1031 >" & _DateTimeFormatEx_vBeta4a('2025/12/30 08:30:00 PM', "dddd d, |h:m tt", 1031) & "<" & @CRLF) ;~ ConsoleWrite("- 1031 >" & _DateTimeFormatEx_vBeta4a('2025/12/30 08:30:00 PM', "d MMMM yyyy", 1031) & "<" & @CRLF) ;~ ConsoleWrite("- 1032 >" & _DateTimeFormatEx_vBeta4a('2025/12/30 08:30:00 PM', "dddd, d MMMM yyyy", 1032) & "<" & @CRLF) ;~ ConsoleWrite("- 1032 >" & _DateTimeFormatEx_vBeta4a('2025/12/30 08:30:00 PM', "dddd d, |h:m tt", 1032) & "<" & @CRLF) ;~ ConsoleWrite("- 1032 >" & _DateTimeFormatEx_vBeta4a('2025/12/30 08:30:00 PM', "d MMMM yyyy", 1032) & "<" & @CRLF) ;~ ConsoleWrite("- 1033 >" & _DateTimeFormatEx_vBeta4a('2025/12/30 08:30:00 PM', "dddd, MMMM d, yyyy", 1033) & "<" & @CRLF) ;~ ConsoleWrite("- 1033 >" & _DateTimeFormatEx_vBeta4a('2025/12/30 08:30:00 PM', "dddd d, |h:m tt", 1033) & "<" & @CRLF) ;~ ConsoleWrite("- 1033 >" & _DateTimeFormatEx_vBeta4a('2025/12/30 08:30:00 PM', "d MMMM yyyy", 1033) & "<" & @CRLF) ;~ ConsoleWrite("- 3082 >" & _DateTimeFormatEx_vBeta4a('2025/12/30 08:30:00 PM', "dddd, d' de 'MMMM' de 'yyyy", 3082) & "<" & @CRLF) ;~ ConsoleWrite("- 3082 >" & _DateTimeFormatEx_vBeta4a('2025/12/30 08:30:00 PM', "dddd d, |h:m tt", 3082) & "<" & @CRLF) ;~ ConsoleWrite("- 3082 >" & _DateTimeFormatEx_vBeta4a('2025/12/30 08:30:00 PM', "d MMMM yyyy", 3082) & "<" & @CRLF) ConsoleWrite("- " & _DateTimeFormatEx_vBeta4a('2025/09/01 08:30:00 PM', "yyyy_MM_dd|_HH_mm_ss") & @CRLF) ;~ ConsoleWrite("- " & _DateTimeFormatEx_vBeta4a('2025/09/01 08:30:00 PM', "|hh.mm.ss tt") & @CRLF) ;~ ConsoleWrite("- " & _DateTimeFormatEx_vBeta4a('2025/09/01 08:30:00 PM', "|HH.mm.ss") & @CRLF) ;~ ConsoleWrite("- " & _DateTimeFormatEx_vBeta4a('2025/09/01 08:30:00 PM', "|H.m") & @CRLF) ;~ ConsoleWrite("- " & _DateTimeFormatEx_vBeta4a('2025/09/01 08:30:00 PM', "|h.m tt") & @CRLF) ;~ Exit _DateTimeFormat_Compare() Func _DateTimeFormat_Compare() Local $aArray[10][8] $aArray[0][0] = " | 0 - date and/or time." $aArray[0][1] = " | 1 - long date, regional settings." $aArray[0][2] = " | 2 - short date, regional settings." $aArray[0][3] = " | 3 - time, regional settings." $aArray[0][4] = " | 4 - time 24-hour (hh:mm)." $aArray[0][5] = " | 5 - time 24-hour (hh:mm:ss)." $aArray[0][6] = " | 6 - time AM/PM (hh:mm tt)." $aArray[0][7] = " | 7 - time AM/PM (hh:mm:ss tt)." _DateTimeFormat_Test($aArray, _NowCalc(), @extended) _DateTimeFormat_Test($aArray, "2025/12/31 11:59:59", @extended) _DateTimeFormat_Test($aArray, "2025/12/31 23:59:59", @extended) _DateTimeFormat_Test($aArray, "2025/12/31 11:59:59 AM", @extended) _DateTimeFormat_Test($aArray, "2025/12/31 11:59:59 PM", @extended) ReDim $aArray[@extended + 1][8] Local $sArray = _SQLite_Display2DResult($aArray, 0, True) ConsoleWrite($sArray) ;~ ClipPut($sArray) ; to share in the forum if there is an error ;~ _DebugArrayDisplay($aArray, "_DateTimeFormat()") EndFunc ;==>_DateTimeFormat_Compare Func _DateTimeFormat_Test(ByRef $aArray, $sNowCalc, $iRow = 0) For $n = 0 To 7 $aArray[$iRow + 1][$n] = " | " & _DateTimeFormatEx_vBeta4a($sNowCalc, $n) Next Return SetError(0, $iRow + 1, "Testing, testing. 1, 2, 3.") EndFunc ;==>_DateTimeFormat_Test Func _DateTimeFormatEx_vBeta4a($sDate, $vType, $iLcid = $LOCALE_USER_DEFAULT) Local $asDatePart[4], $asTimePart[4] Local $sTempDate = "", $sTempTime = "" Local $sAM, $sPM, $sTempString = "" ; Verify If InputDate is valid If Not _DateIsValid($sDate) Then Return SetError(1, 0, "") EndIf ; split the date and time into arrays _DateTimeSplit($sDate, $asDatePart, $asTimePart) If IsInt($vType) Then ; input validation If $vType < 0 Or $vType > 7 Then Return SetError(2, 0, "") EndIf Switch $vType Case 0 $sTempString = _WinAPI_GetLocaleInfo($iLcid, $LOCALE_SSHORTDATE) ; Get short date format. If Not @error And Not ($sTempString = '') Then $sTempDate = $sTempString Else $sTempDate = "M/d/yyyy" EndIf If $asTimePart[0] > 1 Then $sTempString = _WinAPI_GetLocaleInfo($iLcid, $LOCALE_STIMEFORMAT) ; Get short time format. If Not @error And Not ($sTempString = '') Then $sTempTime = $sTempString Else $sTempTime = "h:mm:ss tt" EndIf EndIf Case 1 $sTempString = _WinAPI_GetLocaleInfo($iLcid, $LOCALE_SLONGDATE) ; Get long date format. If Not @error And Not ($sTempString = '') Then $sTempDate = $sTempString Else $sTempDate = "dddd, MMMM dd, yyyy" EndIf Case 2 $sTempString = _WinAPI_GetLocaleInfo($iLcid, $LOCALE_SSHORTDATE) ; Get short date format. If Not @error And Not ($sTempString = '') Then $sTempDate = $sTempString Else $sTempDate = "M/d/yyyy" EndIf Case 3 If $asTimePart[0] > 1 Then $sTempString = _WinAPI_GetLocaleInfo($iLcid, $LOCALE_STIMEFORMAT) ; Get short time format. If Not @error And Not ($sTempString = '') Then $sTempTime = $sTempString Else $sTempTime = "h:mm:ss tt" EndIf EndIf Case 4 If $asTimePart[0] > 1 Then $sTempTime = "HH:mm" EndIf Case 5 If $asTimePart[0] > 1 Then $sTempTime = "HH:mm:ss" EndIf Case 6 If $asTimePart[0] > 1 Then $sTempTime = "hh:mm tt" EndIf Case 7 If $asTimePart[0] > 1 Then $sTempTime = "hh:mm:ss tt" EndIf EndSwitch $sTempTime = " " & $sTempTime Else Local $aPart = StringSplit($vType, "|") $sTempDate = $aPart[1] $sTempTime = "" If $aPart[0] = 2 Then $sTempTime = $aPart[2] EndIf If $asTimePart[0] > 1 Then $sTempString = _WinAPI_GetLocaleInfo($iLcid, $LOCALE_S1159) ; AM designator. If Not @error And Not ($sTempString = '') Then $sAM = $sTempString Else $sAM = "AM" EndIf $sTempString = _WinAPI_GetLocaleInfo($iLcid, $LOCALE_S2359) ; PM designator. If Not @error And Not ($sTempString = '') Then $sPM = $sTempString Else $sPM = "PM" EndIf If (StringInStr($sDate, 'pm') > 0) Or (StringInStr($sDate, $sPM) > 0) Then If $asTimePart[1] < 12 Then $asTimePart[1] += 12 ElseIf (StringInStr($sDate, 'am') > 0) Or (StringInStr($sDate, $sAM) > 0) Then If $asTimePart[1] = 12 Then $asTimePart[1] = 0 EndIf EndIf ; Encode a system time $tSystem = _Date_Time_EncodeSystemTime($asDatePart[2], $asDatePart[3], $asDatePart[1], $asTimePart[1], $asTimePart[2], $asTimePart[3]) Local $sfinalTime = _WinAPI_GetTimeFormat($iLcid, $tSystem, 0, $sTempTime) ; force AM/PM if regional settings not have it If StringInStr($sTempTime, "tt") Then If (StringInStr($sfinalTime, 'pm') = 0) And (StringInStr($sfinalTime, $sPM) = 0) And _ (StringInStr($sfinalTime, 'am') = 0) And (StringInStr($sfinalTime, $sAM) = 0) And _ (StringInStr($sTempTime, "H", 1) = 0) Then If $asTimePart[1] < 12 Then $sfinalTime &= " " & $sAM Else $sfinalTime &= " " & $sPM EndIf EndIf EndIf Local $sResult = "" If $sTempDate <> "" Then $sResult &= _WinAPI_GetDateFormat($iLcid, $tSystem, 0, $sTempDate) If $sTempTime <> "" And $sTempTime <> " " Then $sResult &= $sfinalTime Return $sResult EndFunc ;==>_DateTimeFormatEx_vBeta4a I know that I know nothing
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now