Jump to content

Date.au3


 Share

Recommended Posts

I think the GetDateFormatEx does not do what I thought it did.  I was hoping to pass it a number of a weekday and have it return the name of that day in various languages, but I think that's not it's purpose.

No it's not.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

It's not that it's not. You could do it like this:

#include <WinAPILocale.au3>
#include <StructureConstants.au3>
#include <Date.au3>

ConsoleWrite("Default:" & @CRLF)
For $i = 1 To 7
    ConsoleWrite(@TAB & __DateDayOfWeek($i) & @CRLF)
Next
ConsoleWrite("--------------------------------" & @CRLF)

ConsoleWrite(@CRLF & "0 (LONG_NAME | ENG):" & @CRLF)
For $i = 1 To 7
    ConsoleWrite(@TAB & __DateDayOfWeek($i, 0) & @CRLF)
Next

ConsoleWrite(@CRLF & "1 (SHORT_NAME | ENG):" & @CRLF)
For $i = 1 To 7
    ConsoleWrite(@TAB & __DateDayOfWeek($i, 1) & @CRLF)
Next

ConsoleWrite(@CRLF & "2 (LONG_NAME | LOCALE_USER):" & @CRLF)
For $i = 1 To 7
    ConsoleWrite(@TAB & __DateDayOfWeek($i, 2) & @CRLF)
Next

ConsoleWrite(@CRLF & "3 (SHORT_NAME | LOCALE_USER):" & @CRLF)
For $i = 1 To 7
    ConsoleWrite(@TAB & __DateDayOfWeek($i, 3) & @CRLF)
Next



Func __DateDayOfWeek($iDayNum, $iFormat = Default)
    Local Enum $LONG_NAME = 0, $SHORT_NAME = 1, $LOCALE_USER = 2, $MONDAY_IS_NO1 = 128
    If $iFormat = Default Then $iFormat = 0
    $iDayNum = Int($iDayNum)
    If $iDayNum < 1 Or $iDayNum > 7 Then Return SetError(1, 0, "")
    Local $SYSTEMTIME = DllStructCreate($tagSYSTEMTIME)
    $SYSTEMTIME.Year = BitAND($iFormat, $MONDAY_IS_NO1) ? 2007 : 2006
    $SYSTEMTIME.Month = 1
    $SYSTEMTIME.DayOfWeek = $iDayNum
    $SYSTEMTIME.Day = $iDayNum
    Return _WinAPI_GetDateFormat(BitAND($iFormat, $LOCALE_USER) ? $LOCALE_USER_DEFAULT : $LOCALE_INVARIANT, $SYSTEMTIME, 0, BitAND($iFormat, $SHORT_NAME) ? "ddd" : "dddd")
EndFunc

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

Ah, $tagSYSTEMTIME. Good call.

Edit: I have been creating a build script, so haven't put as much energy into this thread. Sorry.

Edited by guinness

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Yes!  That's what I had thought.  WOnder why I couldn't get it to work?  Oh well, takes a genius I guess.

When I change my language in Region and Language to French as a test, the names changed accordingly!

Bless you, my child.

Link to comment
Share on other sites

Thank you, Father.

Oh and Father, I think setting DayOfWeek for the struct is unnecessary.

Noted.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Mmkay, so yeah, that's pretty much exactly what I was going after.  So, I submit trancexx's function along with the proposed change to the documentation and her example.  I haven't seen how this may affect other functions in Date.au3 which may use this yet.

; #FUNCTION# ====================================================================================================================
; Author ........: trancexx
; Modified.......:
; ===============================================================================================================================
Func _DateDayOfWeek($iDayNum, $iFormat = Default)
    Local Enum $LONG_NAME = 0, $SHORT_NAME = 1, $LOCALE_USER = 2, $MONDAY_IS_NO1 = 128
    If $iFormat = Default Then $iFormat = 0
    $iDayNum = Int($iDayNum)
    If $iDayNum < 1 Or $iDayNum > 7 Then Return SetError(1, 0, "")
    Local $SYSTEMTIME = DllStructCreate($tagSYSTEMTIME)
    $SYSTEMTIME.Year = BitAND($iFormat, $MONDAY_IS_NO1) ? 2007 : 2006
    $SYSTEMTIME.Month = 1
    $SYSTEMTIME.Day = $iDayNum
    Return _WinAPI_GetDateFormat(BitAND($iFormat, $LOCALE_USER) ? $LOCALE_USER_DEFAULT : $LOCALE_INVARIANT, $SYSTEMTIME, 0, BitAND($iFormat, $SHORT_NAME) ? "ddd" : "dddd")
EndFunc

Helpfile

###User Defined Function###
_DateDayOfWeek

###Description###
Returns the name of the weekday, based on the specified day.

###Syntax###
#include <Date.au3>
_DateDayOfWeek ( $iDayNum [, $iFormat = Default] )


###Parameters###
@@ParamTable@@
$iDayNum
    Day number
        1 = Sunday
        2 = Monday
        3 = Tuesday
        4 = Wednesday
        5 = Thursday
        6 = Friday
        7 = Saturday
$iFormat
    [optional] Format:
  0 - Long name of the weekday
  1 - Short name of the weekday e.g. Mon
  2 - Long name of the weekday in the user's default language
  3 - Short name of the weekday in the user's default language
@@End@@

###ReturnValue###
@@ReturnTable@@
Success:    Weekday name
Failure:    An empty string and sets @error to non-zero
@@End@@


###Remarks###
This function returns weekdays names in English or the user's default language.


###Related###
_DateDaysInMonth, _DateToDayOfWeek, _DateToDayOfWeekISO


###Example###
@@IncludeExample@@

Example:

#include <Date.au3>

ConsoleWrite("Default:" & @CRLF)

For $i = 1 To 7
    ConsoleWrite(@TAB & _DateDayOfWeek($i) & @CRLF)
Next

ConsoleWrite(@CRLF & "0 (LONG_NAME | ENG):" & @CRLF)

For $i = 1 To 7
    ConsoleWrite(@TAB & _DateDayOfWeek($i, 0) & @CRLF)
Next

ConsoleWrite(@CRLF & "1 (SHORT_NAME | ENG):" & @CRLF)

For $i = 1 To 7
    ConsoleWrite(@TAB & _DateDayOfWeek($i, 1) & @CRLF)
Next

ConsoleWrite(@CRLF & "2 (LONG_NAME | LOCALE_USER):" & @CRLF)

For $i = 1 To 7
    ConsoleWrite(@TAB & _DateDayOfWeek($i, 2) & @CRLF)
Next

ConsoleWrite(@CRLF & "3 (SHORT_NAME | LOCALE_USER):" & @CRLF)

For $i = 1 To 7
    ConsoleWrite(@TAB & _DateDayOfWeek($i, 3) & @CRLF)
Next

Edit: modified function per post #45

Edited by jaberwocky6669
Link to comment
Share on other sites

$SYSTEMTIME.DayOfWeek = $iDayNum can be commented out (as trancexx said) and just for reference Examples shouldn't use ConsoleWrite() as not everyone has or uses SciTE. MsgBox() is a preferred choice. I will look at this in the next couple of days. Thanks.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

K, one question.  Why is this set to either 2006 or 2007? And why doesn't it work with the current year?

$SYSTEMTIME.Year = BitAND($iFormat, $MONDAY_IS_NO1) ? 2007 : 2006

Edit: actually 2 questions.

Edited by jaberwocky6669
Link to comment
Share on other sites

In the function _DateAdd there is this snippet:

; ====================================================
  ; check if the Input day is Greater then the new month last day.
  ; if so then change it to the last possible day in the month
  Local $iNumDays = _DaysInMonth($asDatePart[1])
  
  If $iNumDays[$asDatePart[2]] < $asDatePart[3] Then $asDatePart[3] = $iNumDays[$asDatePart[2]]

The comment says greater than but the symbol used is a lesser than.  Which one is correct?

Link to comment
Share on other sites

Both ;)

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Can you take a closer look and realize that the code is doing exactly what the comment says it does?

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Yea, thought I indicated as such.  I had the two comparisons confused then I stepped through it more closely.  I guess I did.  Wishing that they were assigned into variable names which gave them more clarity though.

Link to comment
Share on other sites

Modified _DateIsValid to use _DateTimeSplit because it was duplicating the code in the func.

Func _DateIsValid($sDate)  
  Local $asDatePart[4]
  
  Local $asTimePart[4]
  
  _DateTimeSplit($sDate, $asDatePart, $iTimePart)
  
  ; verify valid input date values
  If Not StringIsInt($asDatePart[1]) Then Return 0
  If Not StringIsInt($asDatePart[2]) Then Return 0
  If Not StringIsInt($asDatePart[3]) Then Return 0
  
  ; Make sure the Date parts contains numeric
  $asDatePart[1] = Number($asDatePart[1])
  $asDatePart[2] = Number($asDatePart[2])
  $asDatePart[3] = Number($asDatePart[3])
  
  ; check if all contain valid values
  Local $iNumDays = _DaysInMonth($asDatePart[1])
  If $asDatePart[1] < 1000 Or $asDatePart[1] > 2999 Then Return 0
  If $asDatePart[2] < 1 Or $asDatePart[2] > 12 Then Return 0
  If $asDatePart[3] < 1 Or $asDatePart[3] > $iNumDays[$asDatePart[2]] Then Return 0
  
  ; check Time portion
  If $asTimePart[0] < 1 Then Return 1 ; No time specified so date must be correct
  If $asTimePart[0] < 2 Then Return 0 ; need at least HH:MM when something is specified
  If $asTimePart[0] = 2 Then $asTimePart[3] = "00" ; init SS when only HH:MM is specified
  
  ; Make sure the Time parts contains numeric
  If Not StringIsInt($asTimePart[1]) Then Return 0
  If Not StringIsInt($asTimePart[2]) Then Return 0
  If Not StringIsInt($asTimePart[3]) Then Return 0
  
  ; check if all contain valid values
  $asTimePart[1] = Number($asTimePart[1])
  $asTimePart[2] = Number($asTimePart[2])
  $asTimePart[3] = Number($asTimePart[3])
  
  If $asTimePart[1] < 0 Or $asTimePart[1] > 23 Then Return 0
  If $asTimePart[2] < 0 Or $asTimePart[2] > 59 Then Return 0
  If $asTimePart[3] < 0 Or $asTimePart[3] > 59 Then Return 0
  
  ; we got here so date/time must be good
  Return 1
EndFunc
Link to comment
Share on other sites

Done.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Oops, I must have forgot to check my final changes to that func.

Change

_DateTimeSplit($sDate, $asDatePart, $iTimePart)

To this

_DateTimeSplit($sDate, $asDatePart, $asTimePart)

If you haven't already.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...