| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package SignalWire::Agents::Skills::Builtin::Datetime; |
|
2
|
4
|
|
|
4
|
|
30
|
use strict; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
165
|
|
|
3
|
4
|
|
|
4
|
|
62
|
use warnings; |
|
|
4
|
|
|
|
|
11
|
|
|
|
4
|
|
|
|
|
273
|
|
|
4
|
4
|
|
|
4
|
|
24
|
use Moo; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
27
|
|
|
5
|
4
|
|
|
4
|
|
1699
|
use POSIX qw(strftime); |
|
|
4
|
|
|
|
|
25
|
|
|
|
4
|
|
|
|
|
41
|
|
|
6
|
|
|
|
|
|
|
extends 'SignalWire::Agents::Skills::SkillBase'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
485
|
use SignalWire::Agents::Skills::SkillRegistry; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
3161
|
|
|
9
|
|
|
|
|
|
|
SignalWire::Agents::Skills::SkillRegistry->register_skill('datetime', __PACKAGE__); |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has '+skill_name' => (default => sub { 'datetime' }); |
|
12
|
|
|
|
|
|
|
has '+skill_description' => (default => sub { 'Get current date, time, and timezone information' }); |
|
13
|
|
|
|
|
|
|
has '+supports_multiple_instances' => (default => sub { 0 }); |
|
14
|
|
|
|
|
|
|
|
|
15
|
10
|
|
|
10
|
0
|
2436
|
sub setup { 1 } |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub register_tools { |
|
18
|
9
|
|
|
9
|
0
|
627
|
my ($self) = @_; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
$self->define_tool( |
|
21
|
|
|
|
|
|
|
name => 'get_current_time', |
|
22
|
|
|
|
|
|
|
description => 'Get the current time, optionally in a specific timezone', |
|
23
|
|
|
|
|
|
|
parameters => { |
|
24
|
|
|
|
|
|
|
type => 'object', |
|
25
|
|
|
|
|
|
|
properties => { |
|
26
|
|
|
|
|
|
|
timezone => { type => 'string', description => 'Timezone (e.g. UTC, US/Eastern)', default => 'UTC' }, |
|
27
|
|
|
|
|
|
|
}, |
|
28
|
|
|
|
|
|
|
}, |
|
29
|
|
|
|
|
|
|
handler => sub { |
|
30
|
1
|
|
|
1
|
|
3
|
my ($args, $raw) = @_; |
|
31
|
1
|
|
50
|
|
|
4
|
my $tz = $args->{timezone} // 'UTC'; |
|
32
|
1
|
|
|
|
|
16
|
local $ENV{TZ} = $tz; |
|
33
|
1
|
|
|
|
|
41
|
POSIX::tzset(); |
|
34
|
1
|
|
|
|
|
20
|
my $time = strftime('%H:%M:%S %Z', localtime); |
|
35
|
1
|
|
|
|
|
5
|
POSIX::tzset(); # Reset |
|
36
|
1
|
|
|
|
|
826
|
require SignalWire::Agents::SWAIG::FunctionResult; |
|
37
|
1
|
|
|
|
|
11
|
return SignalWire::Agents::SWAIG::FunctionResult->new( |
|
38
|
|
|
|
|
|
|
response => "The current time in $tz is $time" |
|
39
|
|
|
|
|
|
|
); |
|
40
|
|
|
|
|
|
|
}, |
|
41
|
9
|
|
|
|
|
173
|
); |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$self->define_tool( |
|
44
|
|
|
|
|
|
|
name => 'get_current_date', |
|
45
|
|
|
|
|
|
|
description => 'Get the current date', |
|
46
|
|
|
|
|
|
|
parameters => { |
|
47
|
|
|
|
|
|
|
type => 'object', |
|
48
|
|
|
|
|
|
|
properties => { |
|
49
|
|
|
|
|
|
|
timezone => { type => 'string', description => 'Timezone (e.g. UTC, US/Eastern)', default => 'UTC' }, |
|
50
|
|
|
|
|
|
|
}, |
|
51
|
|
|
|
|
|
|
}, |
|
52
|
|
|
|
|
|
|
handler => sub { |
|
53
|
0
|
|
|
0
|
|
0
|
my ($args, $raw) = @_; |
|
54
|
0
|
|
0
|
|
|
0
|
my $tz = $args->{timezone} // 'UTC'; |
|
55
|
0
|
|
|
|
|
0
|
local $ENV{TZ} = $tz; |
|
56
|
0
|
|
|
|
|
0
|
POSIX::tzset(); |
|
57
|
0
|
|
|
|
|
0
|
my $date = strftime('%Y-%m-%d', localtime); |
|
58
|
0
|
|
|
|
|
0
|
POSIX::tzset(); |
|
59
|
0
|
|
|
|
|
0
|
require SignalWire::Agents::SWAIG::FunctionResult; |
|
60
|
0
|
|
|
|
|
0
|
return SignalWire::Agents::SWAIG::FunctionResult->new( |
|
61
|
|
|
|
|
|
|
response => "The current date in $tz is $date" |
|
62
|
|
|
|
|
|
|
); |
|
63
|
|
|
|
|
|
|
}, |
|
64
|
9
|
|
|
|
|
139
|
); |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub _get_prompt_sections { |
|
68
|
|
|
|
|
|
|
return [{ |
|
69
|
7
|
|
|
7
|
|
70
|
title => 'Date and Time Information', |
|
70
|
|
|
|
|
|
|
body => 'You can get the current date and time in any timezone.', |
|
71
|
|
|
|
|
|
|
bullets => [ |
|
72
|
|
|
|
|
|
|
'Use get_current_time to get the current time', |
|
73
|
|
|
|
|
|
|
'Use get_current_date to get the current date', |
|
74
|
|
|
|
|
|
|
], |
|
75
|
|
|
|
|
|
|
}]; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub get_parameter_schema { |
|
79
|
|
|
|
|
|
|
return { |
|
80
|
2
|
|
|
2
|
0
|
17360
|
%{ SignalWire::Agents::Skills::SkillBase->get_parameter_schema }, |
|
|
2
|
|
|
|
|
46
|
|
|
81
|
|
|
|
|
|
|
}; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |