NAME

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

SYNOPSIS

use LibUI ':all';
use LibUI::VBox;
use LibUI::Window;
use LibUI::TimePicker;
use Time::Piece;
Init && die;
my $window = LibUI::Window->new( 'Schedule an Event', 320, 100, 0 );
$window->setMargined( 1 );
my $box    = LibUI::VBox->new();
my $date   = LibUI::TimePicker->new();
$box->append( $date, 0 );
$date->setTime( Time::Piece->new + ( 30 * 60 ) );    # Half hour from now
$date->onChanged(
    sub {
        my $picker = shift;
        my $t      = $picker->time;
        warn sprintf 'Setting an appointment at %s', $t->time;
    },
    undef
);
$window->setChild($box);
$window->onClosing(
    sub {
        Quit();
        return 1;
    },
    undef
);
$window->show;
Main();

DESCRIPTION

A LibUI::TimePicker object represents a control used to enter a 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::TimePicker->new( );

Creates a new time picker.

onChanged( ... )

$date->onChanged(
sub {
    my ($ctrl, $data) = @_;
    warn $ctrl->time;
}, undef);

Registers a callback for when the 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 time stored in the time picker.

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

setTime( ... )

$date->setTime( localtime );

Sets date and time of the time picker.

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

See Also

LibUI::DateTimePicker - Select a date and 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>