The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

LibUI::DateTimePicker - Control to Enter a Date and Time

SYNOPSIS

    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();

DESCRIPTION

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.

All functions assume local time and do NOT perform any time zone conversions.

Functions

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 - CodeRef that should expect the following:
$date - backreference to the instance that initiated the callback
$data - user data registered with the sender instance
$data - user data to be passed to the callback

Note: The callback is not triggered when calling setTime( ... ).

time( ... )

    warn scalar $date->time;

Returns date and time stored in the date time picker.

By default, this returns a Time::Piece object.

setTime( ... )

    $date->setTime( localtime );

Sets date and time of the data time picker.

You may pass a Time::Piece object or a LibUI::Time structure.

See Also

LibUI::TimePicker - Select a time of day

LibUI::DatePicker - Select a calendar date

LibUI::Time - Wraps the date/time structure

LICENSE

Copyright (C) Sanko Robinson.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

Sanko Robinson <sanko@cpan.org>