LibUI::DateTimePicker - Control to Enter a Date and Time
use LibUI ':all'; use LibUI::VBox; use LibUI::Window; use LibUI::DateTimePicker; use Time::Piece; Init( { Size => 1024 } ) && die; my $window = LibUI::Window->new( 'Schedule an Event', 320, 100, 0 ); my $box = LibUI::VBox->new(); my $date = LibUI::DateTimePicker->new(); $box->append( $date, 0 ); $date->setTime( localtime->add_months(3) ); $date->onChanged( sub { my $picker = shift; my $t = $picker->time; warn sprintf 'Setting an appointment for %s at %s', $t->time, $t->date; }, undef ); $window->setChild($box); $window->onClosing( sub { Quit(); return 1; }, undef ); $window->show; Main();
A LibUI::DateTimePicker object represents a control used to enter a date and time.
All functions operate on struct tm as defined in <time.h> which is wrapped by LibUI::Time.
struct tm
LibUI::Time
All functions assume local time and do NOT perform any time zone conversions.
Not a lot here but... well, it's just a simple widget.
new( )
my $dt = LibUI::DateTimePicker->new( );
Creates a new date and time picker.
onChanged( ... )
$date->onChanged( sub { my ($ctrl, $data) = @_; warn $ctrl->time; }, undef);
Registers a callback for when the date time picker value is changed by the user.
Expected parameters include:
$callback
$date
$data
Note: The callback is not triggered when calling setTime( ... ).
setTime( ... )
time( ... )
warn scalar $date->time;
Returns date and time stored in the date time picker.
By default, this returns a Time::Piece object.
$date->setTime( localtime );
Sets date and time of the data time picker.
You may pass a Time::Piece object or a LibUI::Time structure.
LibUI::TimePicker - Select a time of day
LibUI::DatePicker - Select a calendar date
LibUI::Time - Wraps the date/time structure
Copyright (C) Sanko Robinson.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Sanko Robinson <sanko@cpan.org>
To install LibUI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm LibUI
CPAN shell
perl -MCPAN -e shell install LibUI
For more information on module installation, please visit the detailed CPAN module installation guide.