Hi,

Wx::DateTime->new() gives you the same as wxDefaultDateTime or wxInvalidDateTime, not the current datetime.

What happens when you pass this to Wx::DatePickerCtrl is defined in the docs.

i.e. Wx::DatePickerCtrl will convert to the current datetime.

However, if you pass style wxDP_ALLOWNONE, then Wx::DatePickerCtrl will contain an invalid datetime - which it indicates using an unchecked checkbox. (on mswin at least)

If you don't change the date to a valid one by checking the checkbox, then $pickerctrl->GetValue will return an invalid date. As expected, if you uncheck the checkbox again, the picker control will return an invalid date.

Unfortunately, $pickerctrl->IsValid is not currently wrapped, but you can test as

my $newdate =  $pickerctrl->GetValue;
my $invalid = Wx::DateTime->new();

if($newdate->IsEqualTo($invalid)) {
    #my date is invalid
} else {
    #my date is good
}

You should always check if your datetime values are valid before using them.

->FormatDate will appear work to work on the invalid date. You'll probably get 31 December 1969 (the date part of time_t -1)


Hope this helps

Regards

Mark




Regards

Mark



On 09/10/2010 01:07, Jiří Pavlovský wrote:
On 9.10.2010 1:54, Mark Dootson wrote:
Hi,

Wx::DateTime->new() will give you a default time - so:

That will give a today's date, not empty one which he wants. I don't
knwo whether that is possible?
I also ended up using Wx::DateTime->new()

Reply via email to