Jump to content
Nine

Date Range Picker

Recommended Posts

In this thread, it was asked if there was a Date Range Picker somewhere.  Couldn't find one.  With @Zedna calendar with @maniootek proposal, I felt it could be fun to create one.  So here it is.  Like always, if you have some suggestions, I am open to any.

#include <GUIConstants.au3>
#include <Constants.au3>
#include <FontConstants.au3>
#include <WinAPIRes.au3>
#include <String.au3>
#include <Date.au3>
#include <Misc.au3>
#include <Array.au3>

Global Const $DATERANGE_MONTHS = __DateRange_FormatMonths()
Global Const $DATERANGE_DAYS = __DateRange_FormatDays()

_Example()

Func _Example()
  Local $aReturn = _DateRange_Picker()
  If IsArray($aReturn) Then _ArrayDisplay($aReturn)
EndFunc   ;==>_Example

Func _DateRange_Picker($sTitle = '')

  Local $iMonth1 = Number(@MON)
  Local $iYear1 = Number(@YEAR)
  Local $iMonth2 = Mod($iMonth1, 12) + 1
  Local $iYear2 = $iYear1 + Floor($iMonth1 / 12)

  Local $hGUI = GUICreate($sTitle, 660, 310, -1, -1, $WS_POPUP + $WS_BORDER)
  GUISetBkColor(0xC0C0C0)

  Local $aDay1[42], $aDay2[42], $idMonth1, $idMonth2
  __DateRange_CreateMonth(35, 20, $aDay1, $iMonth1, $iYear1, $idMonth1)
  __DateRange_CreateMonth(375, 20, $aDay2, $iMonth2, $iYear2, $idMonth2)

  Local $idLeft1 = GUICtrlCreateLabel(ChrW(0x276C), 5, 115, 20, 50, $SS_CENTER + $SS_CENTERIMAGE)
  GUICtrlSetFont(-1, 40, $FW_NORMAL, $GUI_FONTNORMAL, "Segoe UI Symbol")
  Local $idRight1 = GUICtrlCreateLabel(ChrW(0x276D), 295, 115, 20, 50, $SS_CENTER + $SS_CENTERIMAGE)
  GUICtrlSetFont(-1, 40, $FW_NORMAL, $GUI_FONTNORMAL, "Segoe UI Symbol")
  Local $idLeft2 = GUICtrlCreateLabel(ChrW(0x276C), 345, 115, 20, 50, $SS_CENTER + $SS_CENTERIMAGE)
  GUICtrlSetFont(-1, 40, $FW_NORMAL, $GUI_FONTNORMAL, "Segoe UI Symbol")
  Local $idRight2 = GUICtrlCreateLabel(ChrW(0x276D), 630, 115, 20, 50, $SS_CENTER + $SS_CENTERIMAGE)
  GUICtrlSetFont(-1, 40, $FW_NORMAL, $GUI_FONTNORMAL, "Segoe UI Symbol")

  Local $idSelect = GUICtrlCreateButton("  " & __DateRange_GetString(800), 240, 270, 80, 35)
  GUICtrlSetImage(-1, "shell32.dll", 253, 0)
  Local $idCancel = GUICtrlCreateButton("  " & __DateRange_GetString(801), 340, 270, 80, 35)
  GUICtrlSetImage(-1, "shell32.dll", 240, 0)

  GUISetState()

  Local $nMsg, $iStart, $iEnd, $aReturn[2], $aPos

  While True
    $aPos = GUIGetCursorInfo($hGUI)
    If $aPos[4] = $idMonth1 Or $aPos[4] = $idMonth2 Then
      GUISetCursor(9, $GUI_CURSOR_OVERRIDE)
    Else
      GUISetCursor()
    EndIf
    $nMsg = GUIGetMsg()
    Switch $nMsg
      Case $GUI_EVENT_CLOSE, $idCancel
        $aReturn = 0
        ExitLoop
      Case $idLeft1 To $idRight2
        If $iStart Then
          __DateRange_SelectDate($aDay1, $aDay2, $iStart, $iEnd, False)
          $iStart = 0
        EndIf
        __DateRange_AdjustDate($nMsg - $idLeft1 + 1, $iMonth1, $iYear1, $iMonth2, $iYear2)
        __DateRange_ShowMonth($aDay1, $iMonth1, $iYear1, $idMonth1)
        __DateRange_ShowMonth($aDay2, $iMonth2, $iYear2, $idMonth2)
      Case $aDay1[0] To $aDay1[UBound($aDay1) - 1], $aDay2[0] To $aDay2[UBound($aDay2) - 1]
        If _IsPressed("10") Then
          If $iStart And $nMsg > $iStart Then
            __DateRange_SelectDate($aDay1, $aDay2, $nMsg, $iEnd, False)
            $iEnd = $nMsg
            __DateRange_SelectDate($aDay1, $aDay2, $iStart, $iEnd, True)
            ContinueLoop
          EndIf
        EndIf
        If $iStart Then __DateRange_SelectDate($aDay1, $aDay2, $iStart, $iEnd, False)
        $iStart = $nMsg
        $iEnd = 0
        __DateRange_SelectDate($aDay1, $aDay2, $iStart, $iEnd, True)
      Case $idSelect
        If Not $iStart Then
          $aReturn = 0
          ExitLoop
        EndIf
        $aReturn[0] = String($iStart < $aDay2[0] ? $iYear1 : $iYear2) & "/" & _
            StringFormat("%02i", $iStart < $aDay2[0] ? $iMonth1 : $iMonth2) & "/" & _
            StringFormat("%02i", GUICtrlRead($iStart))
        If Not $iEnd Then $iEnd = $iStart
        $aReturn[1] = String($iEnd < $aDay2[0] ? $iYear1 : $iYear2) & "/" & _
            StringFormat("%02i", $iEnd < $aDay2[0] ? $iMonth1 : $iMonth2) & "/" & _
            StringFormat("%02i", GUICtrlRead($iEnd))
        ExitLoop
    EndSwitch
  WEnd
  GUIDelete()
  Return $aReturn
EndFunc   ;==>_DateRange_Picker

Func __DateRange_CreateMonth($iPosX, $iPosY, ByRef $aDays, $iMonth, $iYear, ByRef $idMonth)
  Local $iFirst = Mod(_DateToDayOfWeek(String($iYear), StringFormat("%02i", $iMonth), "01") + 5, 7) + 1
  Local $iNumDays = _DateDaysInMonth($iYear, $iMonth)

  $idMonth = GUICtrlCreateLabel($DATERANGE_MONTHS[$iMonth - 1] & " " & $iYear, $iPosX, $iPosY, 250, 30, $SS_CENTER + $SS_CENTERIMAGE, $GUI_WS_EX_PARENTDRAG)
  GUICtrlSetFont(-1, 18, $FW_BOLD, $GUI_FONTNORMAL, "Comic Sans MS")
  GUICtrlSetBkColor(-1, 0xCE04BA)
  For $i = 0 To UBound($DATERANGE_DAYS) - 1
    GUICtrlCreateLabel($DATERANGE_DAYS[$i], $iPosX + 5 + 35 * $i, $iPosY + 35, 30, 25, $SS_CENTER + $SS_CENTERIMAGE)
    GUICtrlSetFont(-1, 12, $FW_NORMAL, $GUI_FONTNORMAL, "Comic Sans MS")
    GUICtrlSetBkColor(-1, 0x808080)
  Next
  For $i = 0 To UBound($aDays) - 1
    $aDays[$i] = GUICtrlCreateLabel("", $iPosX + 5 + Mod($i, 7) * 35, $iPosY + 65 + Floor($i / 7) * 30, 30, 25, $SS_CENTER + $SS_CENTERIMAGE)
    GUICtrlSetFont(-1, 10, $FW_NORMAL, $GUI_FONTNORMAL, "Comic Sans MS")
    If Mod($i, 7) < 5 Then
      GUICtrlSetBkColor(-1, 0xFFFFFF)
    Else
      GUICtrlSetBkColor(-1, 0xA0A0A0)
    EndIf
  Next

  For $i = 0 To $iFirst - 2
    GUICtrlSetState($aDays[$i], $GUI_HIDE)
  Next
  For $i = 0 To $iNumDays - 1
    GUICtrlSetData($aDays[$i + $iFirst - 1], $i + 1)
  Next
  For $i = $iFirst + $iNumDays - 1 To UBound($aDays) - 1
    GUICtrlSetState($aDays[$i], $GUI_HIDE)
  Next

EndFunc   ;==>__DateRange_CreateMonth

Func __DateRange_ShowMonth(ByRef $aDays, $iMonth, $iYear, $idMonth)
  Local $iFirst = Mod(_DateToDayOfWeek(String($iYear), StringFormat("%02i", $iMonth), "01") + 5, 7) + 1
  Local $iNumDays = _DateDaysInMonth($iYear, $iMonth)

  GUICtrlSetData($idMonth, $DATERANGE_MONTHS[$iMonth - 1] & " " & $iYear)
  For $i = 0 To $iFirst - 2
    GUICtrlSetState($aDays[$i], $GUI_HIDE)
  Next
  For $i = 0 To $iNumDays - 1
    GUICtrlSetData($aDays[$i + $iFirst - 1], $i + 1)
    GUICtrlSetState($aDays[$i + $iFirst - 1], $GUI_SHOW)
  Next
  For $i = $iFirst + $iNumDays - 1 To UBound($aDays) - 1
    GUICtrlSetState($aDays[$i], $GUI_HIDE)
  Next
EndFunc   ;==>__DateRange_ShowMonth

Func __DateRange_SelectDate(ByRef $aDay1, ByRef $aDay2, $iStart, $iEnd, $bSelect)
  Local $iDay
  If Not $iEnd Then $iEnd = $iStart
  For $i = $iStart To $iEnd
    If ($i >= $aDay1[0] And $i <= $aDay1[UBound($aDay1) - 1]) Or ($i >= $aDay2[0] And $i <= $aDay2[UBound($aDay2) - 1]) Then
      If $bSelect Then
        GUICtrlSetBkColor($i, 0xFF0000)
      Else
        $iDay = $i < $aDay2[0] ? Mod($i - $aDay1[0], 7) : Mod($i - $aDay2[0], 7)
        If $iDay < 5 Then
          GUICtrlSetBkColor($i, 0xFFFFFF)
        Else
          GUICtrlSetBkColor($i, 0xA0A0A0)
        EndIf
      EndIf
    EndIf
  Next
EndFunc   ;==>__DateRange_SelectDate

Func __DateRange_FormatMonths()
  Local $aMonth[12]
  For $i = 1 To 12
    $aMonth[$i - 1] = _StringTitleCase(_DateToMonth($i, $DMW_LOCALE_LONGNAME))
  Next
  Return $aMonth
EndFunc   ;==>__DateRange_FormatMonths

Func __DateRange_FormatDays()
  Local $aDay[7]
  For $i = 1 To 7
    $aDay[$i - 1] = _StringTitleCase(StringLeft(_DateDayOfWeek(Mod($i, 7) + 1, $DMW_LOCALE_SHORTNAME), 2))
  Next
  Return $aDay
EndFunc   ;==>__DateRange_FormatDays

Func __DateRange_AdjustDate($iAdjust, ByRef $iMonth1, ByRef $iYear1, ByRef $iMonth2, ByRef $iYear2)
  Local $sDate1 = $iYear1 & "/" & StringFormat("%02i", $iMonth1) & "/01"
  Local $sDate2 = $iYear2 & "/" & StringFormat("%02i", $iMonth2) & "/01"

  Switch $iAdjust
    Case 1
      $sDate1 = _DateAdd('M', -1, $sDate1)
    Case 2
      $sDate1 = _DateAdd('M', +1, $sDate1)
      If $sDate1 >= $sDate2 Then $sDate2 = _DateAdd('M', +1, $sDate2)
    Case 3
      $sDate2 = _DateAdd('M', -1, $sDate2)
      If $sDate1 >= $sDate2 Then $sDate1 = _DateAdd('M', -1, $sDate1)
    Case 4
      $sDate2 = _DateAdd('M', +1, $sDate2)
  EndSwitch

  $iMonth1 = Number(StringMid($sDate1, 6, 2))
  $iYear1 = Number(StringMid($sDate1, 1, 4))
  $iMonth2 = Number(StringMid($sDate2, 6, 2))
  $iYear2 = Number(StringMid($sDate2, 1, 4))
EndFunc   ;==>__DateRange_AdjustDate

Func __DateRange_GetString($iNum)
  Local $hInstance = _WinAPI_LoadLibraryEx("user32.dll", $LOAD_LIBRARY_AS_DATAFILE)
  If Not $hInstance Then Return SetError(1, 0, "")
  Local $sText = _WinAPI_LoadString($hInstance, $iNum)
  Local $iErr = @error
  $iNum = @extended
  _WinAPI_FreeLibrary($hInstance)
  If $iErr Then Return SetError(2, 0, "")
  Return SetError(0, $iNum, $sText)
EndFunc   ;==>__DateRange_GetString

Hope you like it.

image.png.bcd97a8fa5c2c63038a4187569d28c1e.png

 

Date Range Picker.au3

Edited by Nine

Share this post


Link to post
Share on other sites

Just for those who downloaded the first version, I corrected a bug where you could select multiple disparate dates.

Share this post


Link to post
Share on other sites

Please consider to change returned values to return them in _Date*() formats.

 

Edited by mLipok

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
Include Dependency Tree (Tool for analyzing script relations)
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) *

PDF Related:https://www.autoitscript.com/forum/topic/177368-how-to-get-reference-to-pdf-object-embeded-in-ie/ *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2020-11-20

Share this post


Link to post
Share on other sites

Why I always get 2 the same date ?

 

 

I suppose/expect to get Range.. I mean "StartDate" .... "EndDate"

 

Edited by mLipok

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
Include Dependency Tree (Tool for analyzing script relations)
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) *

PDF Related:https://www.autoitscript.com/forum/topic/177368-how-to-get-reference-to-pdf-object-embeded-in-ie/ *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2020-11-20

Share this post


Link to post
Share on other sites

Polish translation:

; Polish translation
Global Const $MONTHS = ["Styczeń", "Luty", "Marzec", "Kwiecień", "Maj", "Czerwiec", "Lipiec", "Sierpień", "Wrzesień", "Październik", "Listopad", "Grudzień"]
Global Const $DAYS = ["Pn", "Wt", "Śr", "Cz", "Pt", "So", "Ni"]

 

EDIT:

Better solution:

Global Const $MONTHS = [_DateToMonth(1, $DMW_LOCALE_LONGNAME), _DateToMonth(2, $DMW_LOCALE_LONGNAME), _DateToMonth(3, $DMW_LOCALE_LONGNAME), _DateToMonth(4, $DMW_LOCALE_LONGNAME), _DateToMonth(5, $DMW_LOCALE_LONGNAME), _DateToMonth(6, $DMW_LOCALE_LONGNAME), _DateToMonth(7, $DMW_LOCALE_LONGNAME), _DateToMonth(8, $DMW_LOCALE_LONGNAME), _DateToMonth(9, $DMW_LOCALE_LONGNAME), _DateToMonth(10, $DMW_LOCALE_LONGNAME), _DateToMonth(11, $DMW_LOCALE_LONGNAME), _DateToMonth(12, $DMW_LOCALE_LONGNAME)]
Global Const $DAYS = [_DateDayOfWeek(2, $DMW_LOCALE_SHORTNAME), _DateDayOfWeek(3, $DMW_LOCALE_SHORTNAME), _DateDayOfWeek(4, $DMW_LOCALE_SHORTNAME), _DateDayOfWeek(5, $DMW_LOCALE_SHORTNAME), _DateDayOfWeek(6, $DMW_LOCALE_SHORTNAME), _DateDayOfWeek(7, $DMW_LOCALE_SHORTNAME), _DateDayOfWeek(1, $DMW_LOCALE_SHORTNAME)]

 

Edited by mLipok

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
Include Dependency Tree (Tool for analyzing script relations)
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) *

PDF Related:https://www.autoitscript.com/forum/topic/177368-how-to-get-reference-to-pdf-object-embeded-in-ie/ *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2020-11-20

Share this post


Link to post
Share on other sites

Something is wrong ... 01-11-2020 is not monday, at least in my country ;)

image.png.780cd1412c3226bfe7b215e0548c41d2.png


 

 


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
Include Dependency Tree (Tool for analyzing script relations)
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) *

PDF Related:https://www.autoitscript.com/forum/topic/177368-how-to-get-reference-to-pdf-object-embeded-in-ie/ *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2020-11-20

Share this post


Link to post
Share on other sites

Here is my small modification.

Hope it can became good UDF.

#include <GUIConstants.au3>
#include <Constants.au3>
#include <FontConstants.au3>
#include <Date.au3>
#include <Misc.au3>
#include <Array.au3>

Global Const $DATERANGE_MONTHS = [_DateToMonth(1, $DMW_LOCALE_LONGNAME), _DateToMonth(2, $DMW_LOCALE_LONGNAME), _DateToMonth(3, $DMW_LOCALE_LONGNAME), _DateToMonth(4, $DMW_LOCALE_LONGNAME), _DateToMonth(5, $DMW_LOCALE_LONGNAME), _DateToMonth(6, $DMW_LOCALE_LONGNAME), _DateToMonth(7, $DMW_LOCALE_LONGNAME), _DateToMonth(8, $DMW_LOCALE_LONGNAME), _DateToMonth(9, $DMW_LOCALE_LONGNAME), _DateToMonth(10, $DMW_LOCALE_LONGNAME), _DateToMonth(11, $DMW_LOCALE_LONGNAME), _DateToMonth(12, $DMW_LOCALE_LONGNAME)]
Global Const $DATERANGE_DAYS = [_DateDayOfWeek(2, $DMW_LOCALE_SHORTNAME), _DateDayOfWeek(3, $DMW_LOCALE_SHORTNAME), _DateDayOfWeek(4, $DMW_LOCALE_SHORTNAME), _DateDayOfWeek(5, $DMW_LOCALE_SHORTNAME), _DateDayOfWeek(6, $DMW_LOCALE_SHORTNAME), _DateDayOfWeek(7, $DMW_LOCALE_SHORTNAME), _DateDayOfWeek(1, $DMW_LOCALE_SHORTNAME)]

; English version
;~ Global Const $DATERANGE_MONTHS = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
;~ Global Const $DATERANGE_DAYS = ["Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"]

_Example()
Func _Example()
    Local $aReturn = _DateRange_Picker()
    If IsArray($aReturn) Then _ArrayDisplay($aReturn)
EndFunc   ;==>_Example

Func _DateRange_Picker($sTitle = '')

    Local $iMonth1 = Number(@MON)
    Local $iYear1 = Number(@YEAR)
    Local $iMonth2 = Mod($iMonth1, 12) + 1
    Local $iYear2 = $iYear1 + Floor($iMonth1 / 12)

    Local $hGUI = GUICreate($sTitle, 600, 310, -1, -1, $WS_POPUP + $WS_BORDER)
    GUISetBkColor(0xC0C0C0)

    Local $aDay1[42], $aDay2[42], $idMonth1, $idMonth2
    __DateRange_CreateMonth(35, 20, $aDay1, $iMonth1, $iYear1, $idMonth1)
    __DateRange_CreateMonth(315, 20, $aDay2, $iMonth2, $iYear2, $idMonth2)

    Local $idLeft = GUICtrlCreateLabel(ChrW(0x276C), 5, 115, 20, 50, $SS_CENTER + $SS_CENTERIMAGE)
    GUICtrlSetFont(-1, 40, $FW_NORMAL, $GUI_FONTNORMAL, "Segoe UI Symbol")
    Local $idRight = GUICtrlCreateLabel(ChrW(0x276D), 575, 115, 20, 50, $SS_CENTER + $SS_CENTERIMAGE)
    GUICtrlSetFont(-1, 40, $FW_NORMAL, $GUI_FONTNORMAL, "Segoe UI Symbol")

    Local $idSelect = GUICtrlCreateButton(" Terminer", 250, 265, 100, 35)
    GUICtrlSetImage(-1, "Shell32.dll", 253, 0)

    GUISetState()

    Local $nMsg, $iStart, $iEnd, $aReturn[2][3], $aPos

    While True
        $aPos = GUIGetCursorInfo($hGUI)
        If $aPos[4] = $idMonth1 Or $aPos[4] = $idMonth2 Then
            GUISetCursor(9, $GUI_CURSOR_OVERRIDE)
        Else
            GUISetCursor()
        EndIf
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                $aReturn = 0
                ExitLoop
            Case $idLeft
                If $iStart Then
                    __DateRange_SelectDate($aDay1, $aDay2, $iStart, $iEnd, False)
                    $iStart = 0
                EndIf
                If $iMonth1 = 1 Then
                    $iMonth1 = 12
                    $iYear1 -= 1
                Else
                    $iMonth1 -= 1
                EndIf
                $iMonth2 = Mod($iMonth1, 12) + 1
                $iYear2 = $iYear1 + Floor($iMonth1 / 12)
                __DateRange_ShowMonth($aDay1, $iMonth1, $iYear1, $idMonth1)
                __DateRange_ShowMonth($aDay2, $iMonth2, $iYear2, $idMonth2)
            Case $idRight
                If $iStart Then
                    __DateRange_SelectDate($aDay1, $aDay2, $iStart, $iEnd, False)
                    $iStart = 0
                EndIf
                If $iMonth1 = 12 Then
                    $iMonth1 = 1
                    $iYear1 += 1
                Else
                    $iMonth1 += 1
                EndIf
                $iMonth2 = Mod($iMonth1, 12) + 1
                $iYear2 = $iYear1 + Floor($iMonth1 / 12)
                __DateRange_ShowMonth($aDay1, $iMonth1, $iYear1, $idMonth1)
                __DateRange_ShowMonth($aDay2, $iMonth2, $iYear2, $idMonth2)
            Case $aDay1[0] To $aDay1[UBound($aDay1) - 1], $aDay2[0] To $aDay2[UBound($aDay2) - 1]
                If _IsPressed("10") Then
                    If $iStart And $nMsg > $iStart Then
                        $iEnd = $nMsg
                        __DateRange_SelectDate($aDay1, $aDay2, $iStart, $iEnd, True)
                        ContinueLoop
                    EndIf
                EndIf
                If $iStart Then __DateRange_SelectDate($aDay1, $aDay2, $iStart, $iEnd, False)
                $iStart = $nMsg
                $iEnd = 0
                __DateRange_SelectDate($aDay1, $aDay2, $iStart, $iEnd, True)
            Case $idSelect
                If Not $iStart Then
                    $aReturn = 0
                    ExitLoop
                EndIf
                $aReturn[0][0] = $iStart < $aDay2[0] ? $iYear1 : $iYear2
                $aReturn[0][1] = $iStart < $aDay2[0] ? $iMonth1 : $iMonth2
                $aReturn[0][2] = GUICtrlRead($iStart)
                If Not $iEnd Then $iEnd = $iStart
                $aReturn[1][0] = $iEnd < $aDay2[0] ? $iYear1 : $iYear2
                $aReturn[1][1] = $iEnd < $aDay2[0] ? $iMonth1 : $iMonth2
                $aReturn[1][2] = GUICtrlRead($iEnd)
                ExitLoop
        EndSwitch
    WEnd
    GUIDelete()
    Return $aReturn
EndFunc   ;==>_DateRange_Picker

Func __DateRange_CreateMonth($iPosX, $iPosY, ByRef $aDays, $iMonth, $iYear, ByRef $idMonth)
    Local $iFirst = _DateToDayOfWeek(String($iYear), StringFormat("%02i", $iMonth), "01")
    Local $iNumDays = _DateDaysInMonth($iYear, $iMonth)

    $idMonth = GUICtrlCreateLabel($DATERANGE_MONTHS[$iMonth - 1] & " " & $iYear, $iPosX, $iPosY, 250, 30, $SS_CENTER + $SS_CENTERIMAGE, $GUI_WS_EX_PARENTDRAG)
    GUICtrlSetFont(-1, 18, $FW_BOLD, $GUI_FONTNORMAL, "Comic Sans MS")
    GUICtrlSetBkColor(-1, 0xCE04BA)
    For $i = 0 To UBound($DATERANGE_DAYS) - 1
        GUICtrlCreateLabel($DATERANGE_DAYS[$i], $iPosX + 5 + 35 * $i, $iPosY + 35, 30, 25, $SS_CENTER + $SS_CENTERIMAGE)
        GUICtrlSetFont(-1, 12, $FW_NORMAL, $GUI_FONTNORMAL, "Comic Sans MS")
        GUICtrlSetBkColor(-1, 0x808080)
    Next
    For $i = 0 To UBound($aDays) - 1
        $aDays[$i] = GUICtrlCreateLabel("", $iPosX + 5 + Mod($i, 7) * 35, $iPosY + 65 + Floor($i / 7) * 30, 30, 25, $SS_CENTER + $SS_CENTERIMAGE)
        GUICtrlSetFont(-1, 10, $FW_NORMAL, $GUI_FONTNORMAL, "Comic Sans MS")
        If Mod($i, 7) < 5 Then
            GUICtrlSetBkColor(-1, 0xFFFFFF)
        Else
            GUICtrlSetBkColor(-1, 0xA0A0A0)
        EndIf
    Next

    For $i = 0 To $iFirst - 2
        GUICtrlSetState($aDays[$i], $GUI_HIDE)
    Next
    For $i = 0 To $iNumDays - 1
        GUICtrlSetData($aDays[$i + $iFirst - 1], $i + 1)
    Next
    For $i = $iFirst + $iNumDays - 1 To UBound($aDays) - 1
        GUICtrlSetState($aDays[$i], $GUI_HIDE)
    Next

EndFunc   ;==>__DateRange_CreateMonth

Func __DateRange_ShowMonth(ByRef $aDays, $iMonth, $iYear, $idMonth)
    Local $iFirst = _DateToDayOfWeek(String($iYear), StringFormat("%02i", $iMonth), "01")
    Local $iNumDays = _DateDaysInMonth($iYear, $iMonth)

    GUICtrlSetData($idMonth, $DATERANGE_MONTHS[$iMonth - 1] & " " & $iYear)
    For $i = 0 To $iFirst - 2
        GUICtrlSetState($aDays[$i], $GUI_HIDE)
    Next
    For $i = 0 To $iNumDays - 1
        GUICtrlSetData($aDays[$i + $iFirst - 1], $i + 1)
        GUICtrlSetState($aDays[$i + $iFirst - 1], $GUI_SHOW)
    Next
    For $i = $iFirst + $iNumDays - 1 To UBound($aDays) - 1
        GUICtrlSetState($aDays[$i], $GUI_HIDE)
    Next
EndFunc   ;==>__DateRange_ShowMonth

Func __DateRange_SelectDate(ByRef $aDay1, ByRef $aDay2, $iStart, $iEnd, $bSelect)
    Local $iDay
    If Not $iEnd Then $iEnd = $iStart
    For $i = $iStart To $iEnd
        If ($i >= $aDay1[0] And $i <= $aDay1[UBound($aDay1) - 1]) Or ($i >= $aDay2[0] And $i <= $aDay2[UBound($aDay2) - 1]) Then
            If $bSelect Then
                GUICtrlSetBkColor($i, 0xFF0000)
            Else
                $iDay = $i < $aDay2[0] ? Mod($i - $aDay1[0], 7) : Mod($i - $aDay2[0], 7)
                If $iDay < 5 Then
                    GUICtrlSetBkColor($i, 0xFFFFFF)
                Else
                    GUICtrlSetBkColor($i, 0xA0A0A0)
                EndIf
            EndIf
        EndIf
    Next
EndFunc   ;==>__DateRange_SelectDate

 


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
Include Dependency Tree (Tool for analyzing script relations)
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) *

PDF Related:https://www.autoitscript.com/forum/topic/177368-how-to-get-reference-to-pdf-object-embeded-in-ie/ *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2020-11-20

Share this post


Link to post
Share on other sites
3 hours ago, mLipok said:

Something is wrong ... 01-11-2020 is not monday

Corrected

3 hours ago, mLipok said:

Better solution:

Implemented and using capital first letter (both months and days)

3 hours ago, mLipok said:

Why I always get 2 the same date ?

You need to select a range by using Shift Click for end date ?

4 hours ago, mLipok said:

Please consider to change returned values to return them in _Date*() formats.

Not sure the value of that.

@mLipok Thank you very much for all the tests you made :)

Share this post


Link to post
Share on other sites
6 hours ago, Nine said:

Not sure the value of that.

I mean that you return two dimentionall array where columns are COL0=Year  COL1=Month COL2=Day

But I think better will be 1D Array each row should contain date in format "YYYY/MM/DD" to be fit with _DateIsValid()

 


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
Include Dependency Tree (Tool for analyzing script relations)
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) *

PDF Related:https://www.autoitscript.com/forum/topic/177368-how-to-get-reference-to-pdf-object-embeded-in-ie/ *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2020-11-20

Share this post


Link to post
Share on other sites
6 hours ago, Nine said:

Implemented and using capital first letter (both months and days)

Small issue:

image.png.e8edd468dc4a80401390651864371a16.png

 

This abbreviation is from "Środa"

Edited by mLipok

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
Include Dependency Tree (Tool for analyzing script relations)
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) *

PDF Related:https://www.autoitscript.com/forum/topic/177368-how-to-get-reference-to-pdf-object-embeded-in-ie/ *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2020-11-20

Share this post


Link to post
Share on other sites
6 hours ago, Nine said:

You need to select a range by using Shift Click for end date ?

Nicely done.

But not work when I try to select right to left , I mean from End to Start date.


 


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
Include Dependency Tree (Tool for analyzing script relations)
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) *

PDF Related:https://www.autoitscript.com/forum/topic/177368-how-to-get-reference-to-pdf-object-embeded-in-ie/ *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2020-11-20

Share this post


Link to post
Share on other sites

For comparison... a long time ago I did such a function :

#include <AutoItConstants.au3>
#include <ButtonConstants.au3>
#include <Date.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

_Data_OD_DO('Wybierz zakres dat')

Func _Data_OD_DO($s_info, $data_od = Default, $data_do = Default, $bSQLDateFormat = False, $h_parent_windows = -1) ; Wynik to tablica IDX_0=OD DNIA 'YYYYMMDD 00:00:00.001'   IDX_1=DO DNIA 'YYYYMMDD 23:59:59.990'
    #forceref $h_parent_windows
    If $data_od = Default Then $data_od = _Now()
    If $data_do = Default Then $data_do = _Now()
    $s_info &= @CRLF & @CRLF & 'UWAGA:' & @CRLF & 'Klawisz ESC lub zamknięcie okna jest równoznaczne z naciśnięciem przycisku [ANULUJ]'
    Local $v_GUIOnEventMode = AutoItSetOption("GUIOnEventMode", 0)
    Local $Form_date_from_to = GUICreate("Data od ... do ....", 630, 392, 254, 114)
    GUISetFont(8.5 )
    GUISetBkColor(0xA6CAF0)
    Local $MonthCal_FROM = GUICtrlCreateMonthCal($data_od, 10, 144, 300, 190)
    GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
    Local $MonthCal_TO = GUICtrlCreateMonthCal($data_do, 320, 144, 300, 190)
    GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
    Local $idButton_Wybierz = GUICtrlCreateButton("&Wybierz wskazny zakres dat", 70, 352, 190, 25, $BS_DEFPUSHBUTTON)
    GUICtrlSetBkColor(-1, 0x00FF00)
    GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
    Local $idButton_Anuluj = GUICtrlCreateButton("&Anuluj", 380, 352, 190, 25)
    GUICtrlSetBkColor(-1, 0xFF0000)
    GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
    Local $Label_DATA_OD = GUICtrlCreateLabel("OD DNIA :", 10, 126, 64, 17)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
    Local $Label_DATA_DO = GUICtrlCreateLabel("DO DNIA :", 320, 126, 64, 17)
    GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
    GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
    GUICtrlCreateLabel($s_info, 10, 10, 610, 110, $WS_BORDER, $WS_EX_CLIENTEDGE)
    GUICtrlSetBkColor(-1, 0xFFFBF0)
    GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
    GUISetState(@SW_SHOW)
    Local $nMsg
    Local $vReturnValue = ''
    WinSetOnTop("Data od ... do ....", $s_info, $WINDOWS_ONTOP)
    Local $Days_between
    WinSetOnTop($Form_date_from_to, '', $WINDOWS_ONTOP)
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                $vReturnValue = False
                ExitLoop
            Case $idButton_Wybierz
                $Days_between = _DateDiff('D', GUICtrlRead($MonthCal_FROM), GUICtrlRead($MonthCal_TO))
                If $Days_between < 0 Then
                    GUICtrlSetData($Label_DATA_OD, '!!! DO DNIA :')
                    GUICtrlSetBkColor($Label_DATA_OD, 0xFF0000)
                    GUICtrlSetData($Label_DATA_DO, '!!! DO DNIA :')
                    GUICtrlSetBkColor($Label_DATA_DO, 0xFF0000)
                Else
                    GUICtrlSetData($Label_DATA_OD, 'DO DNIA :')
                    GUICtrlSetBkColor($Label_DATA_OD, 0x000000)
                    GUICtrlSetData($Label_DATA_DO, 'DO DNIA :')
                    GUICtrlSetBkColor($Label_DATA_DO, 0x000000)
                    Local $a_wynik[2] = [GUICtrlRead($MonthCal_FROM), GUICtrlRead($MonthCal_TO)]
                    If $bSQLDateFormat Then
                        $a_wynik[0] = StringReplace($a_wynik[0], '/', '') & ' 00:00:00.001'
                        $a_wynik[1] = StringReplace($a_wynik[1], '/', '') & ' 23:59:59.990'
                    EndIf
                    $vReturnValue = $a_wynik ; 2013/01/01  |   2013/11/08
                    ExitLoop
                EndIf
            Case $idButton_Anuluj
                $vReturnValue = False
                ExitLoop
        EndSwitch
    WEnd
    GUIDelete($Form_date_from_to)
    AutoItSetOption("GUIOnEventMode", $v_GUIOnEventMode)

    If $vReturnValue = False Then _
            Return SetError(1, 0, $vReturnValue)
    Return $vReturnValue
EndFunc   ;==>_Data_OD_DO

 


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
Include Dependency Tree (Tool for analyzing script relations)
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) *

PDF Related:https://www.autoitscript.com/forum/topic/177368-how-to-get-reference-to-pdf-object-embeded-in-ie/ *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2020-11-20

Share this post


Link to post
Share on other sites
2 hours ago, maniootek said:

What if I want select 3 whole months?

At the moment, I will leave it at 2 months, but shouldn't be a big deal for you to add a 3rd month...

Share this post


Link to post
Share on other sites

The idea is that the left and right calendars are independently changeable so that you can set the date range you like.


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
Include Dependency Tree (Tool for analyzing script relations)
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) *

PDF Related:https://www.autoitscript.com/forum/topic/177368-how-to-get-reference-to-pdf-object-embeded-in-ie/ *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2020-11-20

Share this post


Link to post
Share on other sites
52 minutes ago, mLipok said:

This abbreviation is from "Środa"

Problem comes from  _StringTitleCase function.

1 hour ago, mLipok said:

I think better will be 1D Array each row should contain date in format "YYYY/MM/DD" to be fit with _DateIsValid()

Done

1 hour ago, mLipok said:

But not work when I try to select right to left

I know, lets call it a design choice ;)

Share this post


Link to post
Share on other sites
1 hour ago, mLipok said:

For comparison... a long time ago I did such a function

Yep, a different approach, more versatile than mine, but lacking a tiny bit of jazz :)

Share this post


Link to post
Share on other sites

After thinking a moment about your approach, I believe it could be possible to implement it in my GUI.  There is no need to have 2 months in a row, it could be spaced out by a month or more...

Share this post


Link to post
Share on other sites

sounds cool ;)

 


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest beginning - communication with GitHub REST API Forum Rules *
Include Dependency Tree (Tool for analyzing script relations)
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) *

PDF Related:https://www.autoitscript.com/forum/topic/177368-how-to-get-reference-to-pdf-object-embeded-in-ie/ *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2020-11-20

Share this post


Link to post
Share on other sites

@maniootek and @mLipok - Implemented separate months calendar, so it should please you both :sweating:

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...