Modify

Opened 14 years ago

Closed 14 years ago

#2040 closed Bug (No Bug)

_GUICtrlDTP_SetRange; MinYear never goes below 1/1/1752 00:00:00

Reported by: anonymous Owned by: Gary
Milestone: Component: Standard UDFs
Version: 3.3.6.1 Severity: None
Keywords: Cc:

Description

The minimum date never goes below 1/1/1752 00:00:00. What's weird is that it's 1 year behind the default limit. The help file does not mention any thing.

The default limit is 1/1/1753 00:00:00 according to:
http://msdn.microsoft.com/en-us/library/system.windows.forms.datetimepicker.mindate.aspx

The minimum date and time that can be selected in the control. The default is 1/1/1753 00:00:00.

I'd like to get the minimum date at least 1/1/1601 00:00:00 as defined by FILETIME:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms724284%28v=vs.85%29.aspx

Contains a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 
#include <ButtonConstants.au3>
#include <DateTimeConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiDateTimePicker.au3>

_Main()

Func _Main()

	Local $hGUI, $dtpDatePicker, $hDatePicker, $btnOK

	$hGUI = GUICreate("GUICtrlCreateDate", 266, 146, 310, 287)
	GUICtrlCreateGroup("Date", 24, 16, 217, 73)
	$dtpDatePicker = GUICtrlCreateDate("", 40, 48, 186, 21)
	$hDatePicker = GUICtrlGetHandle($dtpDatePicker)
	; OR
;~ 	$hDatePicker = _GUICtrlDTP_Create($hGUI, 40, 48, 186, 21)

	GUICtrlCreateGroup("", -99, -99, 1, 1)
	$btnOK = GUICtrlCreateButton("OK", 160, 104, 75, 25)

	Local $tDTPRange = DllStructCreate($tagDTPRANGE)
	DllStructSetData($tDTPRange, "MinValid", True)
    DllStructSetData($tDTPRange, "MinYear", 1601)
    DllStructSetData($tDTPRange, "MinMonth", 1)
    DllStructSetData($tDTPRange, "MinDay", 1)
	DllStructSetData($tDTPRange, "MinHour", 0)
    DllStructSetData($tDTPRange, "MinMinute", 0)
    DllStructSetData($tDTPRange, "MinSecond", 0)
    DllStructSetData($tDTPRange, "MaxValid", True)
    DllStructSetData($tDTPRange, "MaxYear", @YEAR)
    DllStructSetData($tDTPRange, "MaxMonth", @MON)
    DllStructSetData($tDTPRange, "MaxDay", @MDAY)
    DllStructSetData($tDTPRange, "MaxHour", 12)
    DllStructSetData($tDTPRange, "MaxMinute", 59)
    DllStructSetData($tDTPRange, "MaxSecond", 59)

	_GUICtrlDTP_SetRangeEx($hDatePicker, $tDTPRange)
	$tDTPRange = 0

	; Minimum date is set to 1/1/1601 00:00:00 as defined by FILETIME
	; - http://msdn.microsoft.com/en-us/library/windows/desktop/ms724284%28v=vs.85%29.aspx

	; The minimum date and time that can be selected in the control. The default is 1/1/1753 00:00:00.
	; - http://msdn.microsoft.com/en-us/library/system.windows.forms.datetimepicker.mindate.aspx

	GUISetState(@SW_SHOW)

	While GUIGetMsg() <> $GUI_EVENT_CLOSE
	WEnd
EndFunc

Attachments (1)

untitled.gif (4.7 KB ) - added by anonymous 14 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 by jchd, 14 years ago

Your scipt works as expected on Vista x86 + AutoIt 3.3.6.1 or beta 3.3.7.20: you can select 1601/01/01 in this control. Note that the link you refer to is for a .Net control which may differ from the SysDateTimePick32 control used by the UDF.

by anonymous, 14 years ago

Attachment: untitled.gif added

comment:2 by anonymous, 14 years ago

That's strange because the "Popup date" control works as excepted, but the "Combobox date" control is the one I was referring to.

I'm on Windows XP SP3 x86. Same results for AutoIt 3.3.6.1 and beta 3.3.7.20

comment:3 by jchd, 14 years ago

So this is one more difference between XP and later OSes. Indeed, the XP combo limit is 1752 (the year of adoption of the Gregorian calendar by the UK, BTW). OTOH the popup calendar works fine, except that all versions do allow for pre-September and 03..13/09/1752, i.e. days which never "existed".

Short of building your own control from low-level primitives, I don't believe there's much room for bypassing this XP limit.

in reply to:  3 comment:4 by J-Paul Mesnage, 14 years ago

Replying to jchd:

So this is one more difference between XP and later OSes. Indeed, the XP combo limit is 1752 (the year of adoption of the Gregorian calendar by the UK, BTW). OTOH the popup calendar works fine, except that all versions do allow for pre-September and 03..13/09/1752, i.e. days which never "existed".

Short of building your own control from low-level primitives, I don't believe there's much room for bypassing this XP limit.

so the best is to update the doc to reflect the diff between Vista/7 and XP

comment:5 by Valik, 14 years ago

Resolution: No Bug
Status: newclosed

Closing as no bug. I don't feel documenting this is all that big of a deal. How often do people really need those dates?

Modify Ticket

Action
as closed The owner will remain Gary.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.